Hack of the Year

As you might have noticed, I’ve switched back to using WordPress (again), and managed to dig up all my old blog posts (most of which are utter crap). At the moment I’m using the lighttpd web server, and I had to play around a bit with mod_rewrite in order to get the pretty URLs working. In the end I got lazy and just settled for a hack I found on the Internet. And as a hack, it’s pretty epic.

server.error-handler-404 = "/index.php?error=404"

What it does is thus: when you click on a page in the blog (such as http://www.jackscott.id.au/2009/04/hack-of-the-year), it searches for a folder named 2009 on my web server. That doesn’t exist, so it produces an HTTP 404 error (which means the page doesn’t exist). The rule above (pasted into the lighttpd configuration file) redirects all 404 errors to the index.php file. And this file (as the WordPress main file) just happens to know where to find the page requested. Truly a monumental hack.

The only downside to using this configuration is that Statpress (my favourite WordPress plugin) no longer works properly. It reports the correct number of page views and so on, but all pages requested are listed as ‘error=404‘. Not very useful when you want to see which pages are viewed the most.

But nevertheless, a pretty cool thing.