Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Does anybody have some working Apache mod_rewrite rules that enable Phusion Passenger (mod_rails) to use a non-default location for the page cache within a Rails application? I'd like the cached files to go in /public/cache rather than the default of /public.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

I found the answer in this blog post:

RailsAllowModRewrite On  
RewriteEngine On

RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{REQUEST_URI} ^/([^.]+)$
RewriteCond %{DOCUMENT_ROOT}/cache/%1.html -f
RewriteRule ^/[^.]+$ /cache/%1.html [QSA,L]

RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f
RewriteRule ^/$ /cache/index.html [QSA,L]
share|improve this answer

The answer with RailsAllowModRewrite does not works, as in new versions RailsAllowModRewrite does nothing, but the passenger interaction with mod_rewrite seems to be broken.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.