apache change document root based on url


ServerName testdomain.com
ServerAlias *.testdomain.com

RewriteEngine on
RewriteMap lowercase int:tolower

RewriteCond ${lowercase:%{SERVER_NAME}} ^[a-z0-9-]+\.testdomain\.com$
RewriteRule ^(.+) ${lowercase:%{SERVER_NAME}}$1 [C]

RewriteRule ^([a-z0-9-]+)\.testdomain\.com/(.*) /var/www/vhost/testdomain.com/httpdocs/$1/$2

Leave a Reply

Your email address will not be published.