C:\Windows\System32\drivers\etc\hosts
:
127.0.0.1 www.test.local test.local
C:\xampp\apache\conf\httpd.conf
:
DocumentRoot "D:/htdocs"
<Directory "D:/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
C:\xampp\apache\conf\extra\httpd-vhosts.conf
:
<VirtualHost *:80>
DocumentRoot D:/htdocs
ServerName localhost
<Directory "D:/htdocs">
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot D:/htdocs
ServerName test.local
<Directory "D:/htdocs">
Allow from all
</Directory>
</VirtualHost>
启动Apache时,可以访问localhost
。当我尝试访问test.local
时会出现问题:浏览器返回无法访问此网站消息。就像XAMPP忽略定义到httpd-vhost.conf
文件中的自定义域虚拟主机一样。关闭服务器后也会显示相同的消息。
This site can’t be reached
The webpage at http://test.local/ might be temporarily down or it may have moved permanently to a new web address.
ERR_ADDRESS_INVALID
几天前,安装程序开始运行,而我所做的唯一更改就是安装了新软件。我的意思是,Apache配置文件中没有任何更改。
答案 0 :(得分:1)
答案 1 :(得分:0)
您是否使用这样的映射更新了C:\Windows\System32\drivers\etc\hosts
文件?
hosts
文件的末尾127.0.0.1 test.local
localhost
域无需此映射即可工作,因为操作系统已经将“ localhost”识别为回送IP地址的内置别名(此建议是假设您正在同一台本地计算机上运行和测试)
答案 2 :(得分:0)
C:\ Windows \ System32 \ drivers \ etc
127.0.0.1 test.local
C:\ xampp \ apache \ conf \ extra \ httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "C:/wamp64/www/test"
ServerName test.local
<Directory "C:/wamp64/www/hydroboost/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>