Rewriting old WordPress urls to new site's URL structure via .htaccess
Hey folks, I've migrated a site from WordPress to a new CMS, and I want to preserve the old URLs via a redirect.
The WordPress permalink structure was like so:
/2011/04/01/name-of-post
I've preserved the post slugs, so all I need to do is get rid of the date-based paths and redirect to my new directory structure:
/articles/view/name-of-post
My attempts thus far have looked like this (in my .htaccess file):
RewriteCond %{THE_REQUEST} /[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+) [NC]
RewriteRule ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+)$ /articles/view/$1 [L]
No luck yet. I tried %{PATH_INFO}
in there as well, no dice.
Any 开发者_如何学Gohelp from those more versed in Apache rewrite rules than would be much appreciated.
Something like this should do.
RedirectMatch permanent ^/20../../../(.*)$ /articles/view/$1
It can be handled in one simple RewriteRule like this:
RewriteRule ^[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+)$ /articles/view/$1 [L]
精彩评论