Last Updated: September 09, 2019
· tamasd

Apache dynamic vhosts with

If you want easily use subdirectories as subdomains on your localhost, the best way to do it with apache is using a dynamic vhost configuration with

NameVirtualHost *:80
UseCanonicalName Off

<VirtualHost *:80>
  VirtualDocumentRoot /Users/<username>/Sites/%-7+

The only tricky part here is the %-7+ wildcard. This means that apache will ignore the last 6 parts of the domain name. So if you have then apache will match it to /Users/<username>/Sites/