Posted By

zachharkey on 12/07/09


Tagged

modrewrite


Versions (?)

Mod_rewrite to dynamically map subdomain directories.


 / Published in: Apache
 

Add to vhost block. Dynamically maps all subdomains of sub.example.com to their respective document root. Note: Doesn't work great when the sub sub needs to add additional mod_rewrite rules of its own, i.e., a Drupal installation.

  1. ServerAlias *.sub.example.com
  2.  
  3. RewriteEngine on
  4. RewriteCond %{HTTP_HOST} ^(www\.)?(.+)\.sub\.example\.net
  5. RewriteCond /Users/username/Sites/sub/%2/httpdocs -d
  6. RewriteRule ^(.*) /%2/httpdocs/$1 [L]

Report this snippet  

You need to login to post a comment.