Forum Moderators: phranque

Message Too Old, No Replies

Wrongly posted link giving 404, ok to 301?

         

bleached

10:20 pm on Nov 28, 2008 (gmt 0)

10+ Year Member



Recently I employed a blogger to post with signatures linking to my homepage. However to my surprise by using google analytics i found more than a hundred 404´s as a result of a typo in the URL! The typo is "example.com/</a"

These posts are coming from reputable sites and I feel the link would be worth something. Would it be fine to use a 301 to redirect this to my homepage?

g1smd

11:41 pm on Nov 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, redirect it.

I redirect for a range of common typos and extraneous trailing punctuation that regularly appear due to poor typing and/or the effects of buggy "auto-linking" BBcode from forums and blogs.

bleached

11:50 pm on Nov 28, 2008 (gmt 0)

10+ Year Member



I was thinking a 301 would be a little devious and was in two minds about implementing it. However, an answer from a trusted source I can rest!

Cheers once again g1smd, your advice is gold.

g1smd

12:40 am on Nov 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There's some threads around here showing how to redirect for appended trailing dot and/or quotes and suchlike if you need some starter code to modify. :-)

bleached

1:18 pm on Dec 5, 2008 (gmt 0)

10+ Year Member



g1smd i´m trying to find this thread but with no luck. Could you post it or please tell me how to redirect "example.com/</a" as the is the only one left to do to give me the all OK in google webmaster tools.

Thanks again!

jdMorgan

2:37 pm on Dec 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A simple version:

# Redirect URLs containing valid characters to remove trailing invalid characters
RewriteRule ^([/0-9a-z._\-]*)[^/0-9a-z._\-] http://www.example.com/$1 [NC,R=301,L]

You may need to tweak the [alternate-character-groups] of valid/invalid characters to suit your site's URLs. Both groups must be identical, except that the second one must start with "^" which serves as a NOT operator within a [group].

You can follow this with a second rule that specifically removes trailing punctuation if you like:


RewriteRule ^(.*)[^/0-9a-z]+$ http://www.example.com/$1 [NC,R=301,L]

Because of regex operator precedence and the ambiguity of what constitutes a valid URL, it's difficult and inefficient to combine the two functions, so I just use separate rules.

Jim