homepage Welcome to WebmasterWorld Guest from 54.197.108.124
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.
borisz




msg:4557870
 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)

http://www.example.com/folder/page.php

google also reporting this page

http://www.example.com/folder/page.php/

and this page

http://www.example.com/folder/page.php/another-page-under-folder.php

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.

 

lucy24




msg:4557895
 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
http://www.example.com/folder/page.php/another-page-under-folder.php
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.

borisz




msg:4558005
 2:05 pm on Mar 24, 2013 (gmt 0)

brilliant, your rewrite rule inside .htaccess works.

thanks a lot!

smallcompany




msg:4558803
 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