How to setup Apache when working with virtual hosts in a development environment on local machines.
Uncomment the following lines to allow the VirtualDocumentRoot and CacheDisable directives.
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule cache_module modules/mod_cache.so
Add the following to your vhosts config file. Edit the path in VirtualDocumentRoot and Directory to your folder structure for Apache.
<VirtualHost *:80>
ServerName localhost
VirtualDocumentRoot "/www/htdocs"
</VirtualHost>
<VirtualHost *:80>
UseCanonicalName Off
ServerAlias *.localhost
VirtualDocumentRoot "/www/sites/%0"
<Directory "/www/sites/*">
Options Indexes FollowSymLinks
Require all granted
AllowOverride All
</Directory>
CacheDisable "/"
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
ErrorLog "logs/dev-error.log"
CustomLog "logs/dev-access.log" vcommon
</VirtualHost>
Add the domains to your hosts file, these domains will be redirected to your machine. Note that .localhost is used to avoid conflicts with real sites.
# Dev
127.0.0.1 domain1.localhost
127.0.0.1 domain2.localhost
Make a folder where your sites are located matching the domain name from your hosts file, including the .localhost suffix.
Changed the
.devto.localhostbecause Google registered the.devgTLD which causes some browsers to force SSL.