Old page use underscores, but CMS only supports hyphens
Will a 301 redirect handle this?
fom2001uk
10:02 am on May 13, 2014 (gmt 0)
I want to preserve an old page on a site (long deleted) for link value, but the filename uses underscores. The page can be re-created but only with hyphens (underscores are not supported in the CMS). Will a 301 redirect solve this or not?
lucy24
7:31 pm on May 13, 2014 (gmt 0)
Yes, a redirect can be done for any URL. Since it's just one page, spell out the complete old name on the "pattern" side of the redirect, and the complete new name on the "target" side.
You don't identify your CMS, but if it's any of the big names, it relies heavily on mod_rewrite. So your new redirect needs to go in htaccess before the built-in RewriteRules.
ergophobe
7:11 pm on May 15, 2014 (gmt 0)
This might be a better job for a rewrite rather than a redirect.
A rewrite will mean the URL looks the same in the user's address bar as it always did. Since your CMS is probably using rewrites already as Lucy said, you just add one.
Let's say your page is
example.com/my_great_page
The CMS will let you create example.com/my-great-page
But in an case, it's rewriting this to
example.com/index.php/p=my-great-page
So you could
redirect my-great-page to my_great_page
then rewrite my_great_page to index.php/p=my-great-page
That shouldn't cause an infinite loop. The key question is whether you can control the output of the link to that page. If your CMS is going to force you to show links with underscores, you could have a duplicate content problem. But if you can manually create the link, the above should work and still preserve the original URL.