I have a strange situation occurring on my site where google thinks certain php pages are children of other php pages. For example, I am getting errors in Google Webmaster tools for pages showing up like: http://domain.com/page1.php/page5.php. Both page1.php and page5.php exist on the site, but I can't figure out why google thinks one should be concatenated to the other.
Browsing to such a link will load page1.php, but not correctly. My goal was to use .htaccess (or other suggestions) to simply redirect to the first page if additional pages follow. Am I thinking about this correctly, and can anyone offer suggestions to help me resolve this? Thanks!
Update: The only lines in my .htaccess file are redirecting from a previous folder structure to a single php file, but this has been in place for at least a year. For example:
RedirectMatch 301 ^/widgets/?$ http://firesage.com/widgets.php
Update2: I just found this 'Soft 404' error in Webmaster tools: http://domain.com/page2.php/include/include/lookup.php?id=22. First, I have the include folder excluded via robots.txt. And the fact that the include folder is listed twice in the url is very suspect.
Generally you can use .htaccess
to redirect Google, but I would rather suggest you find the reason why Google sees those "wrong" links (s. Jeroen's comment to your question). Here's the .htaccess
to start up with, until you've found the reason.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Options +FollowSymLinks
# every page on its own
RewriteRule ^page1.php/(.*)$ /page1.php [R=301,L]
RewriteRule ^page2.php/(.*)$ /page2.php [R=301,L]
# or in general maybe the following to replace all of the above, if you think it'll fit
# RewriteRule ^([^/.]+)\.php/(.*)$ /$1.php [R=301,L]
</IfModule>
Update
If you also need to pass any possible GET
parameters, just add the QSA
flag so it becomes [R=301,L,QSA]
.
I'm not an expert at all on .htaccess, but maybe your redirection rules are confused.
To make a redirect, simply use this in your .htaccess:
RewriteEngine On
RewriteRule ^some regex$ http://yourdomain.com/page1.php [L]
Does your .htaccess looks like that ? Could you update your question with it ?
Look for links to page1.php/
instead of page1.php
.
If google (or a browser) follows a link to page1.php/
, the webserver willl deliver the "correct" file page1.php
, but google will think that page1.php
is a directory and therefore interpret relative links (to page2.php
) like they start from an index file in the "directory" page1.php
.