Apache implementation of the local establishment of pan domain name virtual host method

  • 2020-05-10 23:19:57
  • OfStack

This article describes the Apache implementation of the local establishment of pan-domain virtual host method. I will share it with you for your reference as follows:

To set up a pan-domain virtual host locally, you can modify conf/ httpd.conf in the installation directory of Apache, as follows:


<VirtualHost *:80>
ServerName auciou.com
ServerAlias *.auciou.com
DocumentRoot F:/site/auciou
</VirtualHost>

If you restart Apache, you can access it locally using auciou.com and xxx.auciou.com at the same time. xxx is an arbitrary level 2 domain name, which realizes universal domain name resolution. With this method, you can also set up a number of different domain name in the local domain name resolution of the virtual host.

When testing locally, you need to modify the hosts file, open C:\WINDOWS\system32\drivers\etc\hosts and write the following sentence:


127.0.0.1 ww2.auciou.com
127.0.0.1 ww3.auciou.com
127.0.0.1 ww4.auciou.com
127.0.0.1 wwa.auciou.com
127.0.0.1 user.auciou.com
127.0.0.1 blog.auciou.com

Since hosts itself does not have a generic domain name resolution, the level 2 domain name needs to be added to the local hosts file one by one when testing locally. Then manually back up the hosts file and overwrite it after reinstalling the system.

I hope this article has helped you with your Apache server setup.


Related articles: