Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

Changing filepaths from underscores to hyphens

         

lexipixel

1:55 am on Jul 6, 2008 (gmt 0)

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



I have recently changed literally hundreds of directory names and filenames from using underscores to using hyphens. Now all the URLs have hyphens, and the ones indexed in Google have underscores.

Unlike the "Rewrite" fix detailed in:
[webmasterworld.com...]

I do not need to Rewrite anything.

My concern is the 404's for all URLs that had underscores (coming from Google searches).

e.g.-

www.example.com/info/test_dir/my_dog_has_fleas.htm

is now:

www.example.com/info/test-dir/my-dog-has-fleas.htm

I'm looking for opinions...

Would you:

A). Leave it all alone and wait for Google to reindex the site.

B). Put a Redirect in .htaccess with a regular expression to translate all underscores in URLs to hyphens. (For now, I've put a generic 404 that sends all "underscore traffic" to the home page)..

C). Do something else ?

[edited by: tedster at 2:28 am (utc) on July 6, 2008]
[edit reason] moved from another location [/edit]

g1smd

2:07 am on Jul 6, 2008 (gmt 0)

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



A 404 error should return a custom 404 page with relevant error message, links to related content (and maybe also a search box). You should not 404 to your root index page.

In this case, you should use a 301 redirect from the old URLs to the new URLs. That retains traffic coming from *everywhere* that is requesting the old URLs. It also signifies to Google and other sites to update the URLs found.

lexipixel

2:28 am on Jul 6, 2008 (gmt 0)

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



In this case, you should use a 301 redirect from the old URLs to the new URLs. That retains traffic coming from *everywhere* that is requesting the old URLs. It also signifies to Google and other sites to update the URLs found.

The home page 404 was a quick and dirty approach, (98% of the site were these underscore URLs).

Does the limitation on number of hyphens under Apache Rewrite apply to Redirects?

I'm rusty on my regular expressions in .htaccess...

Anyone wanna throw me a 301 rule that means: redirect all traffic for URLs like:

/news/this_is_a_dir/this_is_a_file.htm
/info/this_is_a_dir/this_is_a_file.htm

to:

/news/this-is-a-dir/this-is-a-file.htm
/info/this-is-a-dir/this-is-a-file.htm

All are files and subdirectories of www.example.com/news/ and www.example.com/info/

TIA

[edited by: tedster at 2:38 am (utc) on July 6, 2008]
[edit reason] moved from another location [/edit]

fishfinger

9:31 am on Jul 6, 2008 (gmt 0)

10+ Year Member



A 404 error should return a custom 404 page with relevant error message

Make sure that the HTTP header response is NOT 200 - or Google will index the page.

I read a post to this effect here recently and also saw it in effect on a new site I've just taken on. They have hundreds of 'custom 404' pages indexed.

301 is best. If not then Google will eventually drop 404s from their index but this can take a long time. If there are any links to the internal pages you are wasting them and I believe this means the 404 will hang around for longer.

pageoneresults

9:39 am on Jul 6, 2008 (gmt 0)

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



Apache Web Server Library [webmasterworld.com]

I know jdMorgan keeps the above in tip top shape and I do believe all the code you are looking for are in those referenced tutorials. He's got them pretty well organized so I think you'll find what you are looking for fairly quickly. If not, this might be best served in the Apache Forum.

404s?

Those things will last forever if there are links out there referencing the old URIs. Once you put the 301 in place, you'll never remove it. If you do, the 404s will come back. Yahoo! Slurp and MSNbot will make sure of that. So will Googlebot!

g1smd

10:25 am on Jul 6, 2008 (gmt 0)

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



The 301 is best because it sends all incoming traffic that is asking for the "wrong" URL, directly to the right page on the site, whilst updating the browser address bar to show that new and correct URL.

lexipixel

3:26 pm on Jul 6, 2008 (gmt 0)

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



I agree the 301 is the best approach.

I'm gonna post the request for the 301 rule in Apache forum.

Thanks.