Question

Have a wordpress blog in an older wordpress installation located under the /blog directory. These files have a permalink naming convention of 0000-name-of-file.html. The new wordpress blog location is category/blog, and the new permalink file name convention is name-of-file-0000.html

I was thinking that I would be able to create a rule to redirect/rewrite the name dynamically. But this does not work.

Anyone have any thoughts on what I am doing wrong.

RewriteRule ^/blog/([0-9]{4})-(\d+)\.html $http://www.xyz.com/$2-$1.html [R=302,L]
Was it helpful?

Solution

You can try this rule as first rule in blog/.htaccess:

RewriteRule ^([0-9]+)-(.+)$ /category/blog/$2-$1 [R=302,L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top