mod_rewrite is cool.

As I mentioned in an earlier entry, I recently upgraded by blogging software to WordPress. WordPress uses mod_rewrite to support it’s pretty URL system. This works by defining a set rewrite rules base on regular expressions. For example, every time you call apache internally rewrites the URL as /blog/index.php?year=2005&monthnum=04&name=the-importance-of-a-rare-name. This is not a redirect, the browser thinks it is pointed the pretty URL apache actually uses index.php instead. This behavior is nice, but it lead me to something even better.

I realized today that the perma-links generated by my previous blogging software were now 404s. mod_rewrite to the rescue, I just added a new rule so that the URLs generated are now are rewritten to call WordPress instead. That means that if anyone linked to the existing posts, those links are not broken any more. And it only cost one line in a config file. Now, that is sweet.

Comments 2