Options -MultiViews RewriteEngine On #RewriteBase / # asset redirection RewriteCond %{REQUEST_URI} ^/assets/.*$ RewriteCond %{DOCUMENT_ROOT}/assets/%{HTTP_HOST}/$1 -f RewriteRule ^assets/(.*)$ /assets/%{HTTP_HOST}/$1 [QSA,L] # index redirection RewriteCond %{REQUEST_URI} ^/$ RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}/index.html -f RewriteRule (.*) /cache/%{HTTP_HOST}/index.html [QSA,L] # content redirection RewriteCond %{REQUEST_URI} ^/[^.]+$ RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}%{REQUEST_URI}.html -f RewriteRule (.*) /cache/%{HTTP_HOST}%{REQUEST_URI}.html [QSA,L] # everything else RewriteCond %{REQUEST_URI} ^/.+$ RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}%{REQUEST_URI} -f RewriteRule ^(.*)$ /cache/%{HTTP_HOST}%{REQUEST_URI} [QSA,L] # everything not found goes to Mongrel RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.*) http://127.0.0.1:3001%{REQUEST_URI} [L,P,QSA] #RewriteRule ^/(.*)$ balancer://blogs_cluster%{REQUEST_URI} [P,QSA,L]