Forum Moderators: phranque
Google is visiting a url that causes error through existing .htaccess. I have changed my internal site links to read domain.co.uk/[alphanumeric]-[numeric]-[numeric] this is translating to domain.co.uk/details.php?item_id=$1&cat_id=$2.
The problem is that Google is trying to visit:
domain.co.uk//[alphanumeric]-[numeric]-[numeric]
the // is causing an error. Is it possible to create a .htaccess entry that will 'remove' the forward slash?
I hope you can help me with my problem.
Welcome to WebmasterWorld.
I would look to see why G is asking for that page and try to get any references removed. Until then, this should help:
RewriteEngine ON
RewriteRule ^/([^.]*) http://yoursite.com/$1 [R=301,L]
This will catch any file that starts with a // and rewite it to the correct URL. (The preceding / is stripped by Apache before comparrison in the .htaccess file, so if you use // the rule will not qualify.)
Hope this helps.
Justin
Thank you for your reply. I have adopted your method of stripping one of the first / from the url. I believe it to work but I think that there are some possible conflicts with the other rewrite rules. The site still works using the other rewrite rules (ie the internal site links). I think that google may be doing it to test for optimised urls...what do you think?
Its important that I can get the domain.co.uk/stuff.html to be the same as domain.co.uk//stuff.html
At present i'm getting a 404
here is the main line i'm using that is causing problems with googlebot:
RewriteRule ^([a-zA-Z]*)_([0-9]+)_([0-9]+).html$ item_details.php?item_id=$2&category_id=$3
Hope you can help
Resh