Forum Moderators: phranque

Message Too Old, No Replies

Google Friendly .htaccess

Google is visiting a url that causes error through existing .htaccess

         

resham talawila

9:21 am on Aug 24, 2005 (gmt 0)

10+ Year Member



Dear all,

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.

jd01

7:09 pm on Aug 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi resham,

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

resham talawila

10:05 am on Aug 25, 2005 (gmt 0)

10+ Year Member



Hi 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

jdMorgan

8:21 pm on Aug 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd recommend:

RewriteEngine on
RewriteRule ^/(.*) http://example.com/$1 [R=301,L]
RewriteRule ^([a-zA-Z]+)_([0-9]+)_([0-9]+)[b]\.h[/b]tml$ /item_details.php?item_id=$2&category_id=$3 [b][L][/b]

Jim

resham talawila

10:29 am on Aug 26, 2005 (gmt 0)

10+ Year Member



Thats brilliant!

Thank you very much for all your help. Hope I can be of help in the future.

Kind regards
Resh