nix, shell, perl, php, mysql and mac os x tips and tricks

Wednesday, May 14, 2008

Use mod_rewrite to create "fake sites" (with subdomains) on a single apache vhost

Note: the subdomains need to be server aliases on the vhost
RewriteCond %{HTTP_HOST} ^(subdomain1|subdomain2)\.yoursite\.com [NC]
RewriteRule ^(.*){REQUEST_URI} [L,P]
Apparantly this also works:
RewriteCond %{HTTP_HOST} ^(sub1|sub2)\.yoursite\.com [NC]
RewriteRule (.*)$1 [R=301,L]

No comments:

Post a Comment