Skip to content

Instantly share code, notes, and snippets.

@Maff-
Last active August 29, 2015 14:13
Show Gist options
  • Save Maff-/7bb088ccff6b0b7dc681 to your computer and use it in GitHub Desktop.
Save Maff-/7bb088ccff6b0b7dc681 to your computer and use it in GitHub Desktop.
Dynamic Apache projects vhost
<VirtualHost *:80>
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/projects
<Directory /var/www/projects>
# enable the .htaccess rewrites
AllowOverride All
Require all granted
</Directory>
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error-projects.log
CustomLog ${APACHE_LOG_DIR}/access-projects.log host_combined
#Include conf-available/serve-cgi-bin.conf
RewriteEngine On
RewriteMap lowercase int:tolower
RewriteCond %{REQUEST_URI} ^/icons/
RewriteRule .? - [L]
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]+)\.web\.ruud\.vm$
RewriteRule ^/(.*)$ /var/www/projects/%1/web/$1
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]+)\.ruud\.vm$
RewriteRule ^/(.*)$ /var/www/projects/%1/$1
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment