【问题标题】:Get 403 error when create multiple vhost outside the XAMMP htdocs在 XAMPP htdocs 之外创建多个虚拟主机时出现 403 错误
【发布时间】:2014-01-23 18:24:45
【问题描述】:

我知道这是一个很老的问题,但是在尝试找到正确的解决方案时我没有运气。我已经尝试了所有可能的配置,但仍然没有运气。我正在使用 laravel 开发 PHP 项目。将 laravel.labs 设置为 htdocs 内的虚拟主机时,我完全没有问题。但是当我将它移动到 C:\vhosts 的单独文件夹中时,我得到了这个 403 错误。 vhosts 文件夹的目的是保存多个 vhost。以下是我的配置:

系统: 视窗 7 64 位 XAMPP v 1.7.7 阿帕奇/2.2.21 PHP:5.3.8

httpd.conf:

# Virtual hosts
Include "conf/extra/httpd-vhosts.conf"

httpd-vhosts.conf

NameVirtualHost *:80
<VirtualHost *:80>
  DocumentRoot C:/xampp/htdocs
  ServerName localhost
</VirtualHost>
<VirtualHost *:80>
  DocumentRoot c:/vhosts/laravel_labs/public
  ServerName laravel.labs
</VirtualHost>

c:\windows\system32\driver\etc\host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost
127.0.0.1                   laravel.labs

.htaccess(在 C:\vhosts\laravel_labs\public 内)

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

谁能帮忙找到我错过的东西?有什么建议吗?谢谢

【问题讨论】:

    标签: apache xampp http-status-code-403


    【解决方案1】:

    每次添加新的 Alias 或 DocumentRoot 时,都需要一个 部分,就像默认 DocumentRoot 的部分一样。根据您的版本,这要么有类似的东西

    Order deny,allow 
    

    require all granted
    

    【讨论】:

    • 你是对的。但这对我来说还不够。我在 youtube 上找到了解决方案,我将其发布在下面。谢谢:)
    【解决方案2】:

    我终于找到了这个问题的答案。我必须在 httpd.conf 中添加一些行

    类似这样的:

    Alias /laravel_labs/public "C:/vhosts/laravel_labs/public/"
    <Directory "C:/vhosts/laravel_labs/public/">
        AllowOverride All
        Order Allow,deny
        Allow from all
    </Directory>
    

    请看这里的详细解释: http://www.youtube.com/watch?v=Z250saioXIs

    【讨论】:

      猜你喜欢
      • 2013-07-14
      • 2014-07-30
      • 1970-01-01
      • 2016-05-11
      • 2013-08-24
      • 2018-11-10
      • 2015-09-24
      • 2013-02-19
      • 1970-01-01
      相关资源
      最近更新 更多