Apache mod_rewrite multiple add path info postfix

If you are having strange problems with Apache mod_rewrite, make sure to disable MultiViews with Options -MultiViews (you don’t need it most of the times anyway).

My rewrite rule was something like this:

# /product/WhatEver.php -> /product.php?k=WhatEver
# /product/WhatEver.php?id=12345 -> /product.php?id=12345&k=WhatEver
RewriteRule  ^product/([^/]+)\.php$    product.php?k=$1 [QSA,L]

Found out this after a lot of debugging and searching around the web. First, I enabled mod_rewrite debugging adding these directives:

RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 3

In the log file I found something like:

(3) [perdir /var/www/] add path info postfix: /var/www/product.php -> /var/www/product.php/Test__Test.php
(3) [perdir /var/www/] strip per-dir prefix: /var/www/product.php/Test__Test.php -> product.php/Test__Test.php
(3) [perdir /var/www/] applying pattern '^([0-9]+)/([^/]+)\.php$' to uri 'product.php/Test__Test.php'
(3) [perdir /var/www/] add path info postfix: /var/www/product.php -> /var/www/product.php/Test__Test.php
(3) [perdir /var/www/] strip per-dir prefix: /var/www/product.php/Test__Test.php -> product.php/Test__Test.php
(3) [perdir /var/www/] applying pattern '^prodotto/([^/]+)\.php$' to uri 'product.php/Test__Test.php'
(3) [perdir /var/www/] add path info postfix: /var/www/product.php -> /var/www/product.php/Test__Test.php
(3) [perdir /var/www/] strip per-dir prefix: /var/www/product.php/Test__Test.php -> product.php/Test__Test.php
(3) [perdir /var/www/] applying pattern '^prodotto/([^/]+)\.php?id=([0-9]+)$' to uri 'product.php/Test__Test.php'
(3) [perdir /var/www/] add path info postfix: /var/www/product.php -> /var/www/product.php/Test__Test.php
(3) [perdir /var/www/] strip per-dir prefix: /var/www/product.php/Test__Test.php -> product.php/Test__Test.php
(3) [perdir /var/www/] applying pattern '^c/([^/]+)/([^/]+)\.php$' to uri 'product.php/Test__Test.php'
(1) [perdir /var/www/] pass through /var/www/product.php

The problem was that the request was being modified by MultiViews, substituting /product/ with /product.php and never triggering the mod_rewrite rule.

Grub failing to install on Debian/Ubuntu with GPT partitions

Yesterday we installed Debian 6 on an old rig with an Areca hardware raid controller and 4 2Tb disks in RAID 1+0. Since the volume is so big, we would need to use a GPT partition table, and Debian correctly set it up for us, but after the installation, the machine didn’t boot at all. Booting on the rescue system and chrooting into the installed system to reinstall grub, we obtained this error:

root@debian:~# grub-install /dev/sda
/usr/sbin/grub-setup: warn: This GPT partition label has no BIOS Boot Partition; embedding won't be possible!.
/usr/sbin/grub-setup: warn: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
/usr/sbin/grub-setup: error: if you really want blocklists, use --force.

Turns out, Debian didn’t create a BIOS boot partition for Grub, so we had to create one

root@debian:~# parted /dev/sda
(parted) unit MB
(parted) p free
Model: Areca ARC-1210-VOL#00 (scsi)
Disk /dev/sda: 4000000MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start     End        Size       File system     Name  Flags
 1      0.02MB    4000MB     4000MB     linux-swap(v1)
 2      4000MB    4300MB     300MB      ext3                  boot
 3      4300MB    104300MB   100000MB   ext3
        104300MB  4000000MB  3895700MB  Free Space

(parted) mkpart primary 104300 104400
(parted) p                                                                
Model: Areca ARC-1210-VOL#00 (scsi)
Disk /dev/sda: 4000000MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start     End       Size      File system     Name     Flags
 1      0.02MB    4000MB    4000MB    linux-swap(v1)
 2      4000MB    4300MB    300MB     ext3                     boot
 3      4300MB    104300MB  100000MB  ext3
 4      104301MB  104400MB  99.6MB                    primary

(parted) set 4 bios_grub on                                               
(parted) q                                                                
Information: You may need to update /etc/fstab.
root@debian:~# partprobe /dev/sda
root@debian:~# ls -l /dev/sda*
brw-rw-rw- 1 root root 8, 0 Jul 12 19:02 /dev/sda
brw-rw-rw- 1 root root 8, 1 Jul 12 19:02 /dev/sda1
brw-rw-rw- 1 root root 8, 2 Jul 12 19:02 /dev/sda2
brw-rw-rw- 1 root root 8, 3 Jul 12 18:51 /dev/sda3
brw-rw-rw- 1 root root 8, 4 Jul 12 19:02 /dev/sda4

The magic sits in the command set 4 bios_grub on, which enables the partition as a BIOS Boot partition. Next, we tried again to install grub, successfully:

root@debian:~# grub-install /dev/sda
Installation finished. No error reported.

Edit: info was obtained mostly (but not only) from the wonderful Arch Wiki

How to change claws-mail date format

Since the Mozilla Foundation announced that will scale down/discontinue development on Mozilla Thunderbird, I’ve been checking alternative mail clients.

Claws-mail is a nice client with a number of plugins (most important: GnuPG support), but the default date format was awful on my Fedora 16, so I had to change it. Turns out it’s changed via Configuration -> Preferences under the Display/Summaries section. I changed the default to: %Y-%m-%d %H:%M