I recently tried to tidy up my hand crafted rewrite rules for wordpress/lighttpd and after a very quick google I was taken to an article titled “URL rewriting for wordpress and lighttpd“. Clearly, I thought my search was over. However, I couldn’t help but notice that one of my previous ramblings PHP was resulting in a blank page being rendered.
There was nothing in the error log (although I’m still twiddling with php-fpm and lighttpd) but I realised that my post title (and URL) ended with “php”. Here’s the rewrite rule:
url.rewrite-final = ( # Exclude some directories from rewriting "^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0", # Exclude .php files at root from rewriting "^/(.*.php)" => "$0", # Handle permalinks and feeds "^/(.*)$" => "/index.php/$1" ) }
But the problem is with:
"^/(.*.php)" => "$0",
The single unescaped “.” next to “php” will translate to “any character, followed by php”. What we need is:
"^/(.*\.php)" => "$0",
But, as fate would have it, I only found this out because one of my post titles ended with the word “php”. Filed under coincidence.