New permalink structure: short wordpress urls
As you maybe already know, my permalink structure of the blog was of type http://task3.cc/year/month/day/title-of-the-article/
I’ve just updated the permalink structure to this new one: http://task3.cc/title-of-the-article/
This is nothing difficult, you can set it in Wordpress control panel (Options->Permalinks)
The problem was that, if I just updated the settings in WP control panel, all the links which pointed to my articles, written in forums, mailing lists, etc, would have been broken. I needed a mod_rewrite rule. And I’m a noob about mod_rewriting.
After some googling, I found this awesome mod_rewrite Cheat Sheet which brought me to the solution (after about 30 x /etc/init.d/apache2 reload
):
RewriteEngine On
RewriteBase /
RewriteRule ^200[0-9]/[0-1][0-9]/[0-3][0-9]/(.*)/$ $1/ [R,NC,L]
RewriteRule ^200[0-9]/[0-1][0-9]/[0-3][0-9]/(.*)$ $1/ [R,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
You just need to add two new lines in your mod_rewrite rules, as you see:
RewriteRule ^200[0-9]/[0-1][0-9]/[0-3][0-9]/(.*)/$ $1/ [R,NC,L]
RewriteRule ^200[0-9]/[0-1][0-9]/[0-3][0-9]/(.*)$ $1/ [R,NC,L]
The line basically means:
take the urls which starts with a year (200x) / continue with a month / continue again with a day / contain some text / (with or without the final slash / )
re_write the url just like this: /contain some text/
Yeap, it works! You can try it!
This is my famous article about thermal problems of Amd Turion X2 cpus and Linux (this is the link that Google knows) http://task3.cc/2006/12/02/hp-nx6325-and-friends-thermal-problems-solved/
The link will be redirected to http://task3.cc/hp-nx6325-and-friends-thermal-problems-solved/.
Cool, isn’t that? In this way, you can change your permalinks structure without loosing your google rank


Recent Comments