Apache XAMPP 5.5.38虚拟主机403禁止访问

Apache XAMPP 5.5.38虚拟主机403禁止访问,apache,xampp,virtualhost,Apache,Xampp,Virtualhost,我使用的是Mac OSX 10.7.5和运行Apache2.4的XAMPP5.5.38 当我在地址栏中输入localhost或在etc/hosts文件中配置的任何其他名称时,将显示以下消息: Access forbidden! You don't have permission to access the requested directory. There is either no index document or the directory is read-protected. 这是h

我使用的是Mac OSX 10.7.5和运行Apache2.4的XAMPP5.5.38

当我在地址栏中输入localhost或在etc/hosts文件中配置的任何其他名称时,将显示以下消息:

Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
这是httpd-vhosts.conf

<VirtualHost *:80>
    # get the server name from the 'host:' header
    UseCanonicalName Off
    ErrorLog "logs/myname-error_log"
    DocumentRoot "/Applications/XAMPP/xamppfiles/sites/%0/public_html"
    <Directory /Applications/XAMPP/xamppfiles/sites/%0/public_html>
        DirectoryIndex index.html index.html.var index.php index.php3 index.php4
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
    ServerName localhost
</VirtualHost>
但是,当我更改vhost的顺序时,localhost(在htdocs中)正在工作,任何其他sitename都会重定向到localhost

<VirtualHost *:80>
   DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
   ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    # get the server name from the 'host:' header
    UseCanonicalName Off
    ErrorLog "logs/myname-error_log"
    DocumentRoot "/Applications/XAMPP/xamppfiles/sites/%0/public_html"
    <Directory /Applications/XAMPP/xamppfiles/sites/%0/public_html>
        DirectoryIndex index.html index.html.var index.php index.php3 index.php4
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

DocumentRoot“/应用程序/XAMPP/xamppfiles/htdocs”
服务器名本地主机
#从“主机:”标头获取服务器名称
UseCononicalName关闭
ErrorLog“日志/myname-error\u日志”
DocumentRoot“/Applications/XAMPP/xamppfiles/sites/%0/public_html”
DirectoryIndex.html index.html.var index.php index.php3 index.php4
允许超越所有
要求所有授权
有人能帮我解决这个问题吗?
谢谢

VirtualHost*:80
这种行为是为了让他们捕获相同的“任意”域吗?@Bagus Tesa:yesalright,这里的路径是
/Applications/XAMPP/xamppfiles/sites/%0/public_html
它有
index.html
或类似的东西吗?在osx上我不确定,但我确实担心路径上的
%0
。@BagusTesa是的。如果我将%0替换为mysitename,请执行
ServerName mysitename.local
并删除
usecononicalname Off
,网站将正常工作。但是我不知道为什么它不能与路径中的%0一起工作我认为
useCononicalName Off
不会有问题,因为它只指导apache根据客户端请求头提供的主机和端口构造url。我怀疑原因是
%0
。据我所知,在*nix环境中,
%0
用于检索正在执行的文件,我不确定您想要实现什么。您是否试图让apache根据传递给它的主机名自动匹配目录路径?
<VirtualHost *:80>
   DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
   ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    # get the server name from the 'host:' header
    UseCanonicalName Off
    ErrorLog "logs/myname-error_log"
    DocumentRoot "/Applications/XAMPP/xamppfiles/sites/%0/public_html"
    <Directory /Applications/XAMPP/xamppfiles/sites/%0/public_html>
        DirectoryIndex index.html index.html.var index.php index.php3 index.php4
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>