How to do live.mywebsite.com => mywebsite.com/live via .htaccess?

May 14, 2013 in answer

0 votes, 0.00 avg. rating (0% score)

ANSWER:

Looks like you want VirtualDocumentRoot. For example:


    ServerName mywebsite.com
    ServerAlias www.mywebsite.com
    DocumentRoot /var/www/
    
        Order Allow,Deny
        Allow from all
    


    ServerName subdomains.mywebsite.com
    ServerAlias *.mywebsite.com
    VirtualDocumentRoot /var/www/%-3/
    
        Order Allow,Deny
        Allow from all
    

This will use the third-to-last part of the domain name as a subdirectory under the normal webroot, so live for www.live.mydomain.com and stuff for a.b.c.d.stuff.mydomain.com.

Shane Madden from http://serverfault.com/questions/507856