4

我让 XAMPP 在我的 winodws 8 机器上运行良好的虚拟主机,直到我被迫重新启动计算机(Windows 更新)。重新启动后,我注意到我的虚拟主机不再工作了。我决定重新安装 XAMPP(目前正在运行 XAMPP 3.1.0。这是 runnign Apache v 2.4.3),而不是过多的故障排除

我编辑了我的 Windows 主机文件以重定向sitename.localhost到 127.0.0.1,这就是我在 httpd-vhost.conf 中的内容:

 NameVirtualHost *
      <VirtualHost *>
        DocumentRoot "C:\xampp\htdocs"
        ServerName localhost
      </VirtualHost>
      <VirtualHost *>
        DocumentRoot "C:\Users\USER\Documents\sitename"
        ServerName sitename.localhost
      <Directory "C:\Users\USER\Documents\sitename">
        Order deny,allow
        Allow from all
      </Directory>
    </VirtualHost>

每次我尝试访问http://sitename.localhost时都会收到 403 Access Forbidden 错误。知道我做错了什么吗?

4

3 回答 3

7

尝试添加Require all granted到目录配置:

NameVirtualHost *

<VirtualHost *>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *>
    DocumentRoot "C:\Users\USER\Documents\sitename"
    ServerName sitename.localhost
    <Directory "C:\Users\USER\Documents\sitename">
        Order deny,allow
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

另外,尝试为Authenticated users设置对网站文件夹的读取权限。

于 2013-08-08T14:24:16.843 回答
2

这将作为索引列出。

NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "C:\Users\USER\Documents\sitename"
    ServerName projectname.dev
    ServerAlias projectname.dev
    <Directory "C:\Users\USER\Documents\sitename">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
于 2013-04-02T09:17:54.607 回答
1

你能测试这个代码而不是你的吗?

  <VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
  </VirtualHost>
  <VirtualHost *:80>
    DocumentRoot "C:\Users\USER\Documents\sitename"
    ServerName sitename.localhost
   <Directory "C:\Users\USER\Documents\sitename">
     AllowOverride All
     Order allow,deny
     Allow from all
  </Directory>
</VirtualHost>

顺便说一句,文件夹“C:\Users\USER\Documents\sitename”中是否有 index.html/php 文件,不是吗?

于 2013-01-24T07:29:52.033 回答