Configuring Mephisto to support multiple sites can be confusing. Michael Slater wrote an excellent article describing how to setup multiple sites.

I had some problems with provided mod_rewrite rules. Some of requests never used Mephisto cache. Instead they were always redirected to Mongrel. With mod_rewrite logging turned on and Mephisto production log I was able to tweak it to work on my system running Apache2 and Mongrel.

My working config can be seen below. It is almost identical to Michaels. Main difference is to use RewriteRule (.∗) _ instead of _RewriteRule ^/(.∗)$ and REQUEST_URI instead of REQUEST_FILENAME in several places.

Options -MultiViews

RewriteEngine On

# 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]

You can also download rules from svn.


2 Responses to “Mephisto Multiple Site Config”

  1. acai extreme says:

    wow this was some awesome coding.. I was wondering how i could set up the multiple config for mephisto.. thx a bunch

  2. bv says:

    its now much faster, the caching is much better now, thanks

Leave a Reply



(will not be published)



(you can use Textile for formatting)