Moving Apache rewrite rules from .htaccess to VirtualHost

Using the concrete5 CMS with pretty URLs for a website, I broke it after moving the rewrite rules from .htaccess to the virtual host. Although I use Apache mod_rewrite quite often, I keep forgetting that there are subtle differences between a .htaccess and VirtualHost context. Basically it comes down to relative vs. absolute paths.

For .htaccess concrete5 uses the following rules:


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

For the virtual host I had to change them to:


RewriteEngine On
RewriteRule ^/$ /index.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

Hopefully I will remember it the next time.