Redirect Day and name permalinks to /%postname%/

November 7, 2008 at 8:22 am

If you use the ugly /%year%/%monthnum%/%day%/%postname%/ permalink structure, you should be interested to know how you can switch to the elegant /%postname%/ structure without loosing any backlink, using a simple .htaccess redirection.

The first thing to do is to login to your WordPress admin, go to Settings → Permalinks and select custom. Fill out the field with /%postname%/.
Your permalinks will now look like the ones on this blog:

Now we got to redirect all backlinks using the old permalinks structure to the new permalink structure. To do so, you’ll have to edit the .htaccess file, located in WordPress root directory.
Be careful while editing .htaccess: Always create a backup before!

Paste the following line in your .htaccess:

RedirectMatch 301 /([0-9]+)/([0-9]+)/([0-9]+)/(.*)$$4

Allright! You just changed your permalinks structure without loosing any backlinks!

Credits goes to Joost de Valk newsletter for this awesome recipe!