I am moving a custom coded blog to Wordpress, and also have to setup a redirect which will handle all the blogs.
I have to redirect out of this:
Any applying for grants the regex for any redirect such as this?
Do this mod_rewrite rules:
RewriteEngine on RewriteRule ^(oldblogdirectory/[^_]*)_([^_]*)_(.*) /$1-$2-$3 [N] RewriteRule ^(oldblogdirectory/[^_]*)_(.*) /$1-$2 RewriteRule ^oldblogdirectory/(.+)\.htm$ /newdirectory/$1/ [L,R=301]
As well as the uppercase to lowercase conversion you’ll either require a mapping such as the internal [cde] function or else you use PHP for.
Gumbo's approach is unquestionably the best way to get it done. I made two test sites:
And also the following RewriteRules redirect effectively. They're only slightly transformed to Gumbo's proposal:
Observe that the
RewriteRule ^(oldblogdir/archives/[^_]*)_(.*) $1-$2 [N]
RewriteRule ^oldblogdir/archives/(.*?)\.htm$ newblogdir/archives/$1 [R,NC,L]
causes the .htaccess file to become re-examined before the RegEx no more matches. So that you should place it towards the top from the file.