问题描述
限时送ChatGPT账号..我正在 OSX 上使用内置的 Apache2.我将文档根目录移动到桌面上的一个文件夹中,并确保 _www
和 everyone
具有读取权限.它工作得很好,很好,PHP 工作正常,一切正常,直到我添加了一个 .htaccess
和这一行:
I am working with the built-in Apache2 on OSX. I moved the document root to a folder on my desktop and made sure that _www
and everyone
have read access. It works fine and great, PHP works, everything works until I add a .htaccess
with this line only:
RewriteEngine on
一旦我这样做,文件目录中的所有内容都是 403 Forbidden:
As soon as I do that, everything in the directory with the file is 403 Forbidden:
Forbidden
You don't have permission to access /dir/file.txt on this server.
Apache 日志显示此错误:
Apache logs show this error:
[error] [client 127.0.0.1] 选项 FollowSymLinks 或 SymLinksIfOwnerMatch 已关闭,这意味着禁止 RewriteRule 指令:/Users/uname/桌面/本地主机/目录/文件名.txt
[error] [client 127.0.0.1] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /Users/uname/Desktop/localhost/dir/filename.txt
我已经浏览了 httpd.conf
并确保我已启用 FollowSymLinks
无济于事:
I've gone through httpd.conf
and made sure that I've enabled FollowSymLinks
to no avail:
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>
如果我在 .htaccess
文件中注释掉 RewriteEngine on
,那么一切正常,除了重写规则,显然.在 OSX 10.8.5 上,httpd.conf
位于 /etc/apache2
中,其中还有文件夹 users
包含用于使用的单个文件,例如uname.conf
,但我在这里添加了符号链接,与另一个相同.我注意到还有一个文件夹 extra
包含像 httpd-userdir.conf
这样的文件,但它们似乎没有禁用任何东西.
If I comment out RewriteEngine on
in the .htaccess
file, then everything works fine, except rewrite rules, obviously. On OSX 10.8.5, httpd.conf
is located in /etc/apache2
which also has the folder users
containing individual files for uses, e.g. uname.conf
, but I've added symlinks in here same as in the other. I noticed there's also a folder extra
with files like httpd-userdir.conf
, but they don't seem to disable anything.
还有哪些地方可以打开(或关闭)FollowSymLinks?
Where else can FollowSymLinks be turned on (or off)?
推荐答案
您必须将您的选项放在一行中,或者在您的选项前添加一个 +
符号,以便 Apache 了解您想要的合并它们.目前只应用了最后一个选项指令('Options Indexes MultiViews'),因为它会覆盖所有先前的选项.
You have to either put your Options on one line, or add a +
sign in front of your Options so Apache understands you want merge them. At the moment only the last Options directive ('Options Indexes MultiViews') is being applied since it is overwriting all the prior Options.
试试这个(这将覆盖/"选项):
Try this (which will overwrite the '/' Options):
<Directory "/Users/uname/Desktop/localhost">
Options Indexes MultiViews FollowSymLinks SymLinksIfOwnerMatch
AllowOverride All
Order allow,deny
Allow from all
</Directory>
这篇关于打开 RewriteEngine 会产生 403 错误——如何打开 FollowSymLinks?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论