Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

I figured it out.

In the root .htaccess (in public_html) put:

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

In your subdomain .htaccess (in public_html/subdomain) put:

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

pinax2.fcgi needs to be in the public_html/subdomain/ directory, and pinax.fcgi should be in public_html/

share|improve this answer
    
You deserve more +1s for this - I've been hunting a solution for hours! –  danodonovan Jul 2 '13 at 22:00

Your Answer

 
discard

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.