r4nbzw
Last Updated: February 25, 2016
·
626
· yorirou
6070c18b2f3de0155705b277bbd43f2b

Apache dynamic vhosts with xip.io

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 xip.io.

NameVirtualHost *:80
UseCanonicalName Off

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

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 foo.bar.127.0.0.1.xip.io then apache will match it to /Users/<username>/Sites/foo.bar.

Say Thanks
Respond