Often adding virtual hosts to Apache Web server in development facilitates simultaneous operation of multiple projects, but each time a new project is added
All have to increase the VirtualHost
part, the time has been VirtualHost
partly also many, looked at the headache.
If you use dynamic virtual host, it is more convenient, do not have to configure each time, only need to add a folder, of course, if it is local, you may also need to modify the "hosts" file to add a message,
For example:
Here's how to configure Apache dynamic virtual hosts simply :
1. Open the mod_vhost_alias
module
The Apache httpd.conf file needs to be modified.
2.Apache uses the virtual host name (Server name) to generate self-referencing (self-referential) URLs and more.
When UseCanonicalName Off
the virtual host name (server name) is taken from the contents of the header in the request Host:
.
When UseCanonicalName DNS
, the host name is obtained by DNS anti-resolution of the IP address of the virtual host.
3. Set the directory for the virtual host.
Virtualdocumentroot/www/hosts/%0/docs
/www/hosts/www.aa.com/docs file.
After the configuration is complete, for example: automatically corresponding directory according to the domain name to be accessed
Tips: If you modify the path you need to add directory, different versions of the wording is not very consistent, refer to the original configuration.
For example:
<directory "F:\www" >
Options-indexes +followsymlinks
AllowOverride All
Require all granted
</Directory>
Refer to the official documentation:
1.Dynamically configured Mass Virtual Hosting
2.mod_vhost_alias Module
3.Apache Core Features
Apache Dynamic Virtual Host Configuration