Skip to content

Instantly share code, notes, and snippets.

@devcut
Last active January 15, 2020 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devcut/bb502c460526d733c5ba3deb3582d64d to your computer and use it in GitHub Desktop.
Save devcut/bb502c460526d733c5ba3deb3582d64d to your computer and use it in GitHub Desktop.
Dynamic vhosts
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/devcut/PhpstormProjects/
VirtualDocumentRoot /Users/devcut/PhpstormProjects/%1/public
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
<Directory "/Users/devcut/PhpstormProjects/*/public">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
</Directory>
ErrorLog /var/log/apache2/s4_error.log
CustomLog /var/log/apache2/s4_access.log combined
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment