ModRewriting for Blogger Archives

29th March 2006 @ 2:16 pm
Meta and Blogger
404 errors for nicely formed URLs like www.tom-carden.co.uk/weblog/2006/01 occasionally show up in my stats. It should be really easy to serve something useful (if I wrote anything that month), but Blogger is currently providing me with archives in the form of www.tom-carden.co.uk/weblog/2006_01_01_archive.php which isn't quite right.

Here's the fix I used, for this blog and my p5 blog, in the .htaccess file for www.tom-carden.co.uk:

<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^weblog/([0-9]{4})/([0-9]{1,2})/$ weblog/$1_$2_01_archive.php [L]RewriteRule ^p5/([0-9]{4})/([0-9]{1,2})/$ p5/$1_$2_01_archive.php [L]</IfModule>
Your mileage may vary of course, and I'm aware that the above two rules could easily be just one, but this is good enough for now.

You can try it here: /2006/01/ should be the same as 2006_01_01_archive.php. Not sure what to do about unadorned years though - perhaps just point to January?