Skip to content

Instantly share code, notes, and snippets.

@sndwch
Last active November 1, 2015 19:51
Show Gist options
  • Save sndwch/cb1033dc032eb0fceda2 to your computer and use it in GitHub Desktop.
Save sndwch/cb1033dc032eb0fceda2 to your computer and use it in GitHub Desktop.
Apache/PHP setup for per-developer Environments.
LogLevel debug
<VirtualHost *:80>
ServerAdmin [email protected]
ServerAlias dev.yourserver.com *.dev.yourserver.com
ServerName dev.yourserver.com
RewriteEngine on
RewriteCond %\{HTTP_HOST\} !^www.* [NC]
RewriteCond %\{HTTP_HOST\} ^dev\\.yourserver\\.com(.*)
RewriteRule ^(.*) /var/www/dev/public_html/$1 [L]
RewriteCond %\{HTTP_HOST\} !^www.* [NC]
RewriteCond %\{HTTP_HOST\} ^([^\\.]+)\\.dev\\.yourserver\\.com
RewriteRule ^(.*)$ - [env=host_uname:%1] [N,NS]
RewriteCond %\{HTTP_HOST\} ^([^\\.]+)\\.dev\\.yourserver\\.com(.*)
RewriteRule ^(.*) /var/www/dev/%\{ENV:host_uname\}/public_html/$1 [L]
DocumentRoot /var/www/dev/public_html
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/dev/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
@sndwch
Copy link
Author

sndwch commented Nov 1, 2015

This allows you to have developername.dev.yourserver.com map to /var/www/dev/developername/public_html. Much easier to manage than using ports, etc when using a shared dev environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment