打开 RewriteEngine 会产生 403 错误——如何打开 FollowSymLinks?

2024-02-22

我正在 OSX 上使用内置的 Apache2。我将文档根目录移动到桌面上的一个文件夹中,并确保_www and everyone具有读取权限。它工作得很好,很棒,PHP 工作,一切工作正常,直到我添加一个.htaccess仅此行:

RewriteEngine on

一旦我这样做,包含该文件的目录中的所有内容都是 403 Forbidden:

Forbidden
You don't have permission to access /dir/file.txt on this server. 

Apache 日志显示此错误:

[错误] [客户端 127.0.0.1] 选项关注符号链接 or 符号链接IfOwnerMatch已关闭,这意味着重写规则禁止指令:/Users/uname/Desktop/localhost/dir/filename.txt

我已经经历过httpd.conf并确保我已启用FollowSymLinks无济于事:

DocumentRoot "/Users/uname/Desktop/localhost"
<Directory />
    Options FollowSymLinks
    Options SymLinksIfOwnerMatch 
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<Directory "/Users/uname/Desktop/localhost">
    Options FollowSymLinks
    Options SymLinksIfOwnerMatch 
    Options Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

如果我评论掉RewriteEngine on in the .htaccess文件,然后一切正常,除了重写规则,显然。在 OSX 10.8.5 上,httpd.conf位于/etc/apache2其中还有文件夹users包含单独的文件供使用,例如uname.conf,但我在这里添加了与其他相同的符号链接。我注意到还有一个文件夹extra与类似的文件httpd-userdir.conf,但他们似乎没有禁用任何东西。

还有什么地方可以打开(或关闭)FollowSymLinks?


您必须将选项放在一行上,或者添加一个+在您的选项前面签名,以便 Apache 知道您想要合并它们。目前,仅应用最后一个选项指令(“选项索引多视图”),因为它会覆盖所有先前的选项。

试试这个(这将覆盖“/”选项):

<Directory "/Users/uname/Desktop/localhost">
   Options Indexes MultiViews FollowSymLinks SymLinksIfOwnerMatch
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

打开 RewriteEngine 会产生 403 错误——如何打开 FollowSymLinks? 的相关文章

随机推荐