我试图重定向到本地主机上的一个网页,我已经从主机文件和v-hosts中完成了所有必要的配置,它从我的C:''Windows''System32''drivers''etc主机文件中获取了我的地址,该文件名为.local,但不显示主页。请记住,该站点同时具有前端和后端访问权限。我是新来的,在开始在服务器上编辑应用程序之前,我想在本地处理它。
您发布了包含vhost定义和主机文件内容的附加评论
v-host file
<VirtualHost 127.0.0.1:80>
DocumentRoot "c:/xampp/htdocs/intranet"
ServerName gep.local
ServerAlias gep.local
CustomLog "c:gep.local-access_log" combined
ErrorLog "c:gep.local-error_log"
<Directory "c:/xampp/htdocs/intranet">
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
host file:
127.0.0.1 gep.local
以下是一些建议:-
是否重新启动或重新启动DNS客户端以激活HOSTS文件更改。
from a command window run started using 'Run as Administrator' do this
net stop "DNS Client"
then once it reports as STOPPED
net start "DNS Client"
这将刷新windows DNS缓存。(需要双引号,因为服务名称中有空格)
首先将<VirtualHost 127.0.0.1:80>
更改为<VirtualHost *:80>
如果您使用的是Apache2.2.x,那么还需要一个NameVirtualHost *:80
参数作为vhost定义文件中的第一个参数。如果您使用的是Apache 2.4.x,我相信他们已经删除了这个要求,所以在那个版本的Apache上没有必要这样做。
所以
new v-host file
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/intranet"
ServerName gep.local
ServerAlias gep.local
CustomLog "c:/gep.local-access_log" combined
ErrorLog "c:/gep.local-error_log"
<Directory "c:/xampp/htdocs/intranet">
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
当然,要测试它,请使用地址`http://gep.local',以访问此新的虚拟主机。