Skip to content

Instantly share code, notes, and snippets.

@John2496
Last active December 27, 2015 14:39
Show Gist options
  • Save John2496/7341965 to your computer and use it in GitHub Desktop.
Save John2496/7341965 to your computer and use it in GitHub Desktop.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
<VirtualHost *:80>
RewriteEngine On
RewriteMap lowercase int:tolower
# If already rewitten and we have the right path, stop right here
RewriteCond /var/www/vhosts/${lowercase:%{SERVER_NAME}/public} !-d
RewriteRule ^/(.*)$ /var/www/vhosts/_default/public/$1 [L,E=VHOST_ROOT:/var/www/vhosts/_default/public]
RewriteRule ^(/var/www/vhosts/[^/]+/.*)$ $1
RewriteRule ^(.+) ${lowercase:%{SERVER_NAME}}$1
# Strip out dev subdomain from hostname
##RewriteRule ^(.*).dev.(.*) $1.$2
#RewriteRule ^(.*)dev.(.*) $1$2
#RewriteRule ^(.*).dev(.*) $1$2
RewriteRule ^(www\.)?([^/]+)/(.*)$ /var/www/vhosts/$2/public/$3 [E=VHOST_ROOT:/var/www/vhosts/$2/]
Options +Indexes +FollowSymLinks
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment