Skip to content

Instantly share code, notes, and snippets.

@sethwhitaker
Last active August 29, 2015 14:12
Show Gist options
  • Save sethwhitaker/468e1900e96bebb22356 to your computer and use it in GitHub Desktop.
Save sethwhitaker/468e1900e96bebb22356 to your computer and use it in GitHub Desktop.
Custom vhosts (Mac OSX - webserver)
# This is a Dynamic vhosts config.
# With this config, you wont need to add new entries for each project.
# Just add entry to hosts file
# Just replace all 'username' text with your actual machine username
# Reset for defualt localhost
<VirtualHost *:80>
DocumentRoot "/Users/username/Sites"
ServerName localhost
</VirtualHost>
# 1. Project root is the same as web root.
# Ex: /Users/foo/Sites/bar
# Hosts Entry: 127.0.0.1 bar.dev
<VirtualHost *:80>
UseCanonicalName Off
ServerAlias *.dev
VirtualDocumentRoot "/Users/username/Sites/%1"
<Directory "/Users/username/Sites/*">
SetEnv ENV dev
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
# 2. Project web root one level deep.
# Ex: /Users/foo/Sites/bar/www
# Hosts Entry: 127.0.0.1 bar.local
# /www can be changed to anything which suits your projects
<VirtualHost *:80>
UseCanonicalName Off
ServerAlias *.local
VirtualDocumentRoot "/Users/username/Sites/%1/www"
<Directory "/Users/username/Sites/*/www">
SetEnv ENV dev
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment