Return to Snippet

Revision: 21224
at December 7, 2009 10:24 by zachharkey


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

Revision: 21223
at December 7, 2009 10:22 by zachharkey


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

Initial URL

                                

Initial Description
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.

Initial Title
Mod_rewrite to dynamically map subdomain directories.

Initial Tags

                                

Initial Language
Apache