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
.
Written by Tamás Demeter-Haludka
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Apache
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#