Rails/Wordpress/Apache/Passenger - not working with custom permalinks



I’m trying to get an installation of wordpress working in a blog
directory under /public in a rails app. The webserver is Apache using
phusion passenger.

I’ve tried following the instructions in this blog post

Everything works fine if I just use the normal Wordpress permalink
structure. However, once I customise the permalinks none of the
patterns seem to be being matched in my .htaccess and the request
passes to the rails router where it of course fails.

This is in my .htaccess

RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} ^/blog/\d+.*
RewriteRule . /blog/index.php [L]
RewriteRule ^/blog$ /blog/index.php [QSA]
RewriteRule ^(/blog./$)$ $1/index.php [QSA]
RewriteRule ^/blog/?(.
)$ %{DOCUMENT_ROOT}/blog/$1 [NC,QSA,L]

Hopefully someone on this list can help.