Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using wildcard dns / apache / mod-rewrite, I want to achieve the following:

clientname.clients.company.com -> /home/company.com/clients/clientname

I've tried rewrite rules, such as:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^\.]+)\.clients\.company\.com
RewriteCond /home/clients\.company\.com/%1 -d
RewriteRule ^(.*) /%1/$1 [L]

none of them seem to work with the *.clients.company.com model - I'm getting an infinite loop error.

share|improve this question

It looks like you're basically trying to setup dynamically configured mass virtual hosting. A simpler configuration would be to use mod_vhost_alias. The %1 substitution will contain the first part of the hostname, so the following will set the document root appropriately.

UseCanonicalName    Off
VirtualDocumentRoot /home/company.com/clients/%1

(You could actually avoid hardcoding most of the path with /home/%3-/%2/%1.)

share|improve this answer
    
Great, I'll give that a shot today - thank you for your suggestion. – David Verner May 21 '12 at 14:37

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.