Changing your permalink structure
I recently changed the permalink structure of this Wordpress blog, going from /%year%/%monthnum%/%day%/%postname%/ (Wordpress default i think) to the much more elegant and simple /%postname%/. This is very cool ofcourse, both because it's simpler and SEO wise, but on an existing blog, this leaves you with lots of links that point to the wrong URL. If you're running your blog on Apache, the solution is quite simple, if you can tweak your .htaccess file or your Apache config.
The solution can be found in one single RedirectMatch line. This line should be placed above the Wordpress code, or in the Apache config. The line is the following:
[sourcecode language="php"]
RedirectMatch 301 /([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ http://www.domain.com/$4
[/sourcecode]
This matches every URL which starts with a date, and permanently redirects it to the new URL for this post. Ofcourse you could be running your blog in a subdirectory, like I am, in that case, the line would be:
[sourcecode language="php"]
RedirectMatch 301 /subdir/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$
http://www.domain.com/subdir/$4
[/sourcecode]
This way, all your incoming links will still work, and thus count for SearchEngines and you have the benefits of the new URL structure.
[tags]wordpress, apache, seo, permalinks, htaccess[/tags]
Related posts
- Move your WordPress blog to a new domain in 10 steps!
- Google, WordPress and trackback URL's
- Fixed category subpage titles and a fix in permalink redirect plugin
- WordPress theming: pushing trackbacks down
- Trailing double forward slashes in URL's in the SERPs...






