1. Edit D: \ XAMPP \ apache \ conf \ httpd. conf in notepad and add the port to be listened on at the top, for example, 8081. Retain the default listening port 80.
Listen 80
Listen 8081.
2. Add:
<Virtualhost *: 8081>
Servername localhost // local address. You can try to use 127.0.0.1 or 192.168.1 .**
DocumentRoot D: \ XX // point to your url
<Directory/>
Require all granted
</Directory>
</Virtualhost>
3. Restart Apache (XAMPP ).
If you want to add a custom domain name and browse it, follow these steps:
1. Configure the domain name (any): www.a.com, point to 127.0.0.1 (Local Machine)
(1) Open c: \ windows \ system32 \ drivers \ etc \ hosts in Notepad
(2) Add the following code at the bottom of the file and save it:
127.0.0.1 www.a.com // in this way, browsing www.a.com will point to the Local Machine
2. Edit D: \ XAMPP \ apache \ conf \ httpd. conf.
<Virtualhost *: 8081>
Servername www.a.com
DocumentRoot D: \ XX // point to your url
<Directory/>
Require all granted
</Directory>
</Virtualhost>
/* ===================================================== ========================================================== ======= */
Note:
1. The following is the configuration version of virtualhost. Please refer to and reference it.
<Virtualhost *: 80>
Serveradmin [email protected]
DocumentRoot "/XAMPP/htdocs/www. ABC. TLD"
Servername www. ABC. TLD
Errorlog "logs/www. ABC. tld-error.log"
Customlog "logs/www. ABC. tld-access.log" combined
</Virtualhost>
2. Note the following:
As stated in the preceding section, if an error occurs again, you can open tools such as xampp_start.exe to clear the mine.