Forum Moderators: phranque
Since these pages have rankings, I need to do a 301 redirect to keep them that way. Is there a good automated way to do this redirection? Or am I going to have to do "RedirectPermanent /Second_First.html [domainname.com...] for all of the pages I have. Any help is greatly appreciated. Thank You!
Be sure to have your backup .htaccess handy as I've been known to give an incorrect example ;)
mod_alias
RedirectMatch 301 ^(.*)_(.*)\.html$ ht*p://www.yoursite.com/$2-$1.html
mod_rewrite
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)_(.*)\.html$ /$2-$1.html [R=301,L]
But, I think you are going to need two lines because your example should only redirect URLs in the second level directories. You will still need one for the files in the root directory.
RedirectMatch 301 ^/(.*)_(.*)\.html$ h*tp://www.domainname.com/$1/$3-$2.html
RedirectMatch 301 ^/(.*)/(.*)_(.*)\.html$ h*tp://www.domainname.com/$1/$3-$2.html