php apache 服务器上的 500 错误 - “此处不允许使用 AllowOverride”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20154232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:55:33  来源:igfitidea点击:

500 Error on apache server - "AllowOverride not allowed here"

phpmacosapache.htaccesshttpd.conf

提问by Tom

I have set up a server on my Mac (OSX 10.9) but it's returning a 500 error with the following message in the error log…

我已经在我的 Mac (OSX 10.9) 上设置了一个服务器,但它返回 500 错误并在错误日志中显示以下消息......

[alert] [client ::1] /Users/user/Sites/mysite/.htaccess: AllowOverride not allowed here

Here's the code in my .htaccess file

这是我的 .htaccess 文件中的代码

Options +FollowSymLinks -MultiViews
AllowOverride All

# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteMap lc int:toLower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^i/(.*)/(.*)-(.*)$ /items/?id=&range=&type= [L,QSA,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^c/(.*)$ /category/?menu= [L,QSA,NC]

And here's the relevant httpd.conf code (let me know if there's anything else that would help)

这是相关的 httpd.conf 代码(让我知道是否还有其他有用的东西)

DocumentRoot "/Users/user/Sites/mysite"

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
</Directory>

<Directory "/Users/user/Sites/mysite">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Any ideas?

有任何想法吗?

回答by Jon Lin

AllowOverride Alldoesn't belong in the htaccess file. It's used in the server config (httpd.conf) to set what an server config parameters an htaccess file can override. So obviously, it would be wrong to be able to configure what parameters htaccess files can override from within htaccess files.

AllowOverride All不属于 htaccess 文件。它在服务器配置 (httpd.conf) 中用于设置 htaccess 文件可以覆盖的服务器配置参数。很明显,能够配置 htaccess 文件可以从 htaccess 文件中覆盖的参数是错误的。

Remove it from your htaccess file. You've already defined AllowOverride Allin your httpd.conf in the right places.

从您的 htaccess 文件中删除它。您已经AllowOverride All在 httpd.conf 中的正确位置进行了定义。

回答by tr0y

AllowOverride controls .htaccess-security and -behaviour and could not be set inside of .htaccess files.

AllowOverride 控制 .htaccess-security 和 -behaviour,不能在 .htaccess 文件中设置。

Drop "AllowOverride All" from .htaccess, thats all.

从 .htaccess 中删除“AllowOverride All”,仅此而已。

回答by Dave

Take AllowOverride All out of your .htaccess.

从您的 .htaccess 中取出 AllowOverride All。