0

我正在我的计算机上本地开发一个 Wordpress 站点。我有两个 Wordpress 安装,一个在C:\xampp\htdocs\wordpress内,另一个在C:\My_Sites\medicalproject\wordpress

我安装了 XAMPP,并通过键入localhost/wordpress访问第一个安装。第二次我创建了一个名为medicalproject的虚拟主机并访问它,我只需打开我的浏览器并输入medicalproject

一切都很顺利,直到我尝试创建另一个主机用于测试目的。我看到它不起作用,所以我删除了新的虚拟主机,只剩下一个医疗项目。但问题并没有解决。发生的情况是浏览器(FF、IE、Chrome、Opera)无法识别medicalproject,而是运行谷歌搜索。Apache 正常启动,我可以访问localhostlocalhost/wordpress,这是第一次安装。

我提到当我尝试添加第二个虚拟主机时,Avira Free Antivirus 阻止了对主机文件的访问,您必须在该文件中添加本地主机的环回 IP(127.0.0.1 和服务器名称)。我禁用了该功能,重新启动了几次并尝试但没有运气。

下面是我的 httpd-vhosts.conf 的样子。我提到这个确切的配置以前是有效的。

## Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
    ##ServerAdmin postmaster@dummy-host.localhost
    ##DocumentRoot "C:/xampp/htdocs/dummy-host.localhost"
    ##ServerName dummy-host.localhost
    ##ServerAlias www.dummy-host.localhost
    ##ErrorLog "logs/dummy-host.localhost-error.log"
    ##CustomLog "logs/dummy-host.localhost-access.log" combined
##</VirtualHost>

##<VirtualHost *:80>
    ##ServerAdmin postmaster@dummy-host2.localhost
    ##DocumentRoot "C:/xampp/htdocs/dummy-host2.localhost"
    ##ServerName dummy-host2.localhost
    ##ServerAlias www.dummy-host2.localhost
    ##ErrorLog "logs/dummy-host2.localhost-error.log"
    ##CustomLog "logs/dummy-host2.localhost-access.log" combined
##</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    Servername localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:\My_Sites\medicalproject\wordpress"
    ServerName medicalproject
    ErrorLog "C:\My_Sites\medicalproject\medicalproject.error.log"
    CustomLog "C:\My_Sites\medicalproject\medicalproject.access.log" combined
  <Directory "C:\My_Sites\medicalproject\wordpress">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
4

0 回答 0