Using the Redirection Plugin to Strip Dates from Incoming Links
A lot of bloggers initally set permalinks to use dates in the url. Whether it’s because you had a blog at wordpress.com (or Blogger) or because that was how other people did it, you may have changed your mind and decided that you just want to use the post name in your permalink. Is it too late to change it now that you’ve got dozens/hundreds/thousands of links back to your posts?
Nope. You can use a 301 redirect to continue passing link juice (and passing the people who click on those links) to your posts while changing your permalink structure to just the post titles.
The way I’m going to show you involves using the Redirection plugin for Wordpress created by Urban Giraffe. I suggest turning off the logs after you’ve got a couple days showing you that it works, otherwise this can bog down your database or keep you emptying logs. You can also do this using .htaccess, but this solution is so simple that you don’t have to be a code guru to use it.
How to Change Your Permalinks
Go to Settings -> Permalinks
Scroll down to “Custom Structure” and paste in:
/%postname%/
Make sure there are no spaces before or after! Then Save. Go to your blog to make sure that it worked right.
How to Redirect Year/Month/Day
Starting with the Year/Month/Day/Post-Title format because it’s the most common. If you’re using it, your urls look like http://blogcrafted.com/2010/05/24/post-title. If you’re just using Year or Year/Month, I’ll address that in a minute.
Activate Redirection and go to the main page.
In the “Source URL” box, paste:
/(\d*)/(\d*)/(\d*)/(.*)
Leave match set to “Url only” and Action “Redirect to URL.” Check the “Regular Expression” box.
In “Target URL” box, paste:
/$4
Click here to see an image of how this looks
That’s it! Click “Add Redirection” and test it out. To change internal links, check out this tutorial on removing dates from internal links.
How to Redirect if You’re Just Using Year/Month or Year
So here’s the secret to how that code works. Every (\d*) is a series of numbers. So what we’re telling Redirection to do in the previous section is to look for three series of numbers of any length, followed by (.*), a series of characters of any length and to redirect that to just the 4th item in the series, namely the characters.
There are other ways to achieve the same goal. We could set the numbers at (\d{4}) for the year & (\d{2}) for the month & day, since a year has 4 numbers and months and days have 2. But we don’t need to. All we have to do is tell Redirection how many sets of numbers we’re removing (and be sure to include the / between the numbers) and then tell it what to return (i.e. where in the sequence the data it should return is).
If that was all Greek to you, then here’s the short answer.
If you’re stripping out Year/Month (http://blogcrafted.com/2010/05/post-title), then use:
/(\d*)/(\d*)/(.*) as the Source URL and /$3 as the Target URL.
If you’re stripping out just the year (http://blogcrafted.com/2010/post-title), then use:
/(\d*)/(.*) as the Source URL and /$2 as the Target URL.
Voila.
Note, this tutorial is only for Wordpress, and only for the Redirection plugin, not for your .htaccess file.
If the redirect doesn’t work, make sure there are no spaces in it and if it still doesn’t work, delete. Setting up this redirect is also a service I offer, so contact me if you need someone else to do it for you.

{ 1 trackback }
{ 3 comments }
thanks, this was really helpful. I couldn’t get it quite right until I saw this.
Wow! That’s beautiful, thank you you for posting such a simple explanation.
Ditto the above commentators. The Redirection plugin was pointed my way, pun intended, but the official docs are confusing as heck. This told me exactly what to do. Thanks!
Comments on this entry are closed.