homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Slash appear at the end of every url
Problems with slash appearing at the end of every url on my website.

Msg#: 4557868 posted 11:16 pm on Mar 23, 2013 (gmt 0)

I have problem with my website because Google is reporting duplicate content on it, even if those pages (static pages) don't appear on the server. For example if I have page at this location (this is static and not dynamic page)


google also reporting this page


and this page


this slash (/) appear at the end of every page on my website. Anyone knows what is causing it to appear and how to get rid of it? I did checked .htaccess file and he is not causing this problem.

Thanks for help.



WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

Msg#: 4557868 posted 1:46 am on Mar 24, 2013 (gmt 0)

I did checked .htaccess file and he is not causing this problem.

It may not be causing the problem, but it may be failing to prevent the problem.

In ordinary static html, directories have slashes at the end and files don't. If your site is made up of php files built on the fly, then you need to transfer the slash-checking job to the php itself. Whenever there is a request for anything that doesn't exist-- including pages with name ending in ".php/" --your php has to return a 404.

If your filenames end in php but are essentially static, you can handle it the same way you'd handle it with html. Does this type of URL
really occur? If not, make a single conditionless rule that says something like
RewriteRule ^(([^./]+/)*[^./]+\.(html|php))/ http://www.example.com/$1 [R=301,L]

No closing anchor, so there might be extra stuff after the superflous slash. I have this rule on my test site, though so far I haven't needed to add it in real life.


Msg#: 4557868 posted 2:05 pm on Mar 24, 2013 (gmt 0)

brilliant, your rewrite rule inside .htaccess works.

thanks a lot!


WebmasterWorld Senior Member 5+ Year Member

Msg#: 4557868 posted 4:34 am on Mar 27, 2013 (gmt 0)

I had the same problem some time ago. It created thousands of non-existent pages across one of my sites.
This is what I used:

RewriteRule ^([^.]+\.+html)/$ http://www.example.com/$1 [R=301,L]

I guess lucy24's way of doing it is more comprehensive, so stick with it.
In Google WMT, just select all of the pages that appear, and mark them as fixed. Don't get surprised if many of new ones start appearing every day.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved