mod_rewrite rules to run fcgi for different subdomains

Posted by Anthony Hiscox on Server Fault See other posts from Server Fault or by Anthony Hiscox
Published on 2011-01-29T21:55:25Z Indexed on 2011/01/29 23:27 UTC
Read the original article Hit count: 289

On my shared hosting server (Hostmonster) I have django (actually pinax) setup so that a .htaccess mod_rewrite rule rewrites the request to a pinax.fcgi file:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ pinax.fcgi/$1 [QSA,L]

What I would like to do is have a different pinax.fcgi file get called depending on the domain used (or subdomain), something like this:

RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ pinax2.fcgi/$1 [QSA,L]


RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ pinax.fcgi/$1 [QSA,L]

This is stored in a .htaccess file in my ROOT public_html folder (not in the public_html/subdomain/ folder), but unfortunately just results in internal redirect errors. How can I write these rules so that they use a different fcgi file for different domains?

© Server Fault or respective owner

Related posts about apache

Related posts about mod-rewrite