Skip to content

Instantly share code, notes, and snippets.

@jimrubenstein
Created July 28, 2014 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jimrubenstein/5f5de7c01ff220017e98 to your computer and use it in GitHub Desktop.
Save jimrubenstein/5f5de7c01ff220017e98 to your computer and use it in GitHub Desktop.
Dynamic sub-domain -> sub-folder webroot rewriting (more documentatino here: http://stackoverflow.com/a/17890602/109026)
# goes in folder that holds symlinks to project files (/home/jim/sites/dev)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.local.dev
RewriteCond %1::%{REQUEST_URI} !^(.*?)::/\1/
RewriteRule ^(.*)$ /%1/$1 [L]
RewriteCond %{HTTP_HOST} ^([^.]+)\.dev\.local
RewriteCond %1::%{REQUEST_URI} !^(.*?)::/\1/
RewriteRule ^(.*)$ /%1/$1 [L]
<VirtualHost *:80>
ServerName local.dev
ServerAlias *.local.dev *.local
DocumentRoot "/home/jim/sites/dev" #folder for symlinks to project files
Options Indexes FollowSymLinks
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment