Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
I would have thought canonical URLs would have taken care of that, but you’re getting 404s back so it’s not.
If I understand it correctly, you want this
http://www.example.com/2011/10/7639/cateogry/post_name/
to become just this
http://www.example.com/post_name/
Or put differently
http://www.example.com/$1/$2/$3/$4/$5/
becomes
http://www.example.com/$5/
If so, try this above your WordPress rules in .htaccess
# Old URLs to new
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Rewriterule ^(.*)/(.*)/(.*)/(.*)/(.*)/ http://your-blog-url/$5/ [L]
</IfModule>
# BEGIN WordPress
See if that works for you.
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
I forgot this part, if that does work put the response code 301 into that rewrite rule like so
Rewriterule ^(.*)/(.*)/(.*)/(.*)/(.*)/ http://your-blog-url/$5/ [R=301,L]
That will tell the search engines that the URLs are permanently moved to the new location.
http://www.example.com/2011/10/7639/category/post_name/ would be easier if you locked down the YYYY/MM slugs first…
My first shot would be this:
RewriteRule ^([0-9]{4})/([0-9]{2})/(.*)/category/(.*)$ http://domain.com/$4 [L,R=301]
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
Okay, after a sidebar conversation, this seems to be it:
# Old URLs to new
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9].*)/(.*)/(.*)$ http://your-blog-url/$4/ [L,R=301]
</IfModule>
# BEGIN WordPress
The original one I posted breaks things like the visual editor. This one is more specific with the ####/##/numbers-here/category/slug pattern.
Very cool.. thanks everyone… 🙂
I couldn’t tell you an exact name, but I’m 99% sure there is a plugin for that. “Redirection” comes to mind, but I didn’t go off and research it.
I assume there is a plugin for it because you aren’t exactly the first person to ever change their permalink structure after a large post base has been built, so I would make sure to do some research on that.