我尝试使用以下.htaccess值来托管基于php的应用程序。
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine On
RewriteBase /easydeposit
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
但是,我一直面临以下两个错误,
[access_compat:error] [pid 25330:tid 27] AH01797: client denied by server configuration: /home/abc/opt/apache/htdocs/xyz/system/
[access_compat:error] [pid 25330:tid 27] AH01797: client denied by server configuration: /home/abc/opt/apache/htdocs/xyz/private/
[access_compat:error] [pid 25330:tid 27] AH01797: client denied by server configuration: /home/abc/opt/apache/htdocs/xyz/application/
[authz_core:error] [pid 25330:tid 27] AH01630: client denied by server configuration: /home/abc/opt/apache/htdocs/xyz/.htaccess
我不确定为什么会这样。任何帮助表示赞赏。
答案 0 :(得分:57)
如果您最近升级到版本大于2.2的Apache,则authz_core错误错误可能来自<Document>
标记中的httpd.conf或httpd-vhosts.conf文件。 mod_authz_core是在Apache 2.3中引入的,并改变了声明访问控制的方式。
因此,例如,而不是2.2方式配置<Directory>
...
<Directory "C:/wamp">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
订单和允许指令已替换为需要指令:
<Directory "C:/wamp">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
源头 http://www.andrejfarkas.com/2012/06/fun-with-wamp-server-and-apache-2-4-2/ http://httpd.apache.org/docs/2.4/upgrading.html
答案 1 :(得分:4)
这个问题/答案让我感谢documentation感谢我,以下是为我解决的问题。
上一个.htaccess
文件:
# password protection allowing multiple resources
AuthType Basic
AuthName "Restricted Area"
AuthUserFile C:\path\to\.htpasswd
AuthGroupFile /dev/null
Require valid-user
# allow public access to the following resources
SetEnvIf Request_URI "(path/to/public_files/.*)$" allow
# these lines must be updated
Order allow,deny
# Allowing an ip range:
Allow from 69.69.69
# Allowing another range:
Allow from 71.71.71
Satisfy any
此配置产生如下错误:
[Thu Dec 08 10:29:20.347782 2016] [access_compat:error] [pid 2244:tid 15876] [client 93.93.93.93:49340] AH01797:客户端被服务器配置拒绝:C:/ path / to / index .PHP
针对2.4配置进行了更新
# 7 lines unchanged...shown again for clarification
AuthType Basic
AuthName "Restricted Area"
AuthUserFile C:\path\to\.htpasswd
AuthGroupFile /dev/null
Require valid-user
SetEnvIf Request_URI "(path/to/public_files/.*)$" allow
# these are the changes replacing:
# Order allow,deny
# Allow from <range>
# Satisfy any
Require ip 69.69.69
Require ip 71.71.71
Require all granted
答案 2 :(得分:2)
我怀疑这与你的htaccess文件有什么关系。 mod_access_compat会引发错误,提供Allow
,Deny
,Order
和Satisfy
指令。在某个地方,你可能有你的允许和拒绝配置错误。至于最后的.htaccess错误,它来自mod_authz_core,所以上游可能会阻止对.htaccess文件的访问。
答案 3 :(得分:0)
您确定允许覆盖.htaccess文件中的选项吗?检查主要的apache配置文件
答案 4 :(得分:0)
Options +FollowSymLinks
Options -Indexes
很多共享主机上面的代码经常出现主要问题
答案 5 :(得分:0)
您完全确定apache用户(可能是_www)可以访问目录(/home/abc/opt/apache/htdocs/xyz/
)吗?
答案 6 :(得分:0)
另一个例子,改写自:
www.yoursite.com/script.php?product=123
到
www.yoursite.com/cat/product/123/
使用
RewriteRule cat/(.*)/(.*)/$ /script.php?$1=$2
http://w3webtutorial.blogspot.com/2013/11/htaccess-and-modrewrite-in-your-php.html
答案 7 :(得分:0)
对我来说,wp-config文件夹中有一个.htaccess文件,其中包含这些条目
Order deny,allow
Deny from all
<Files ~ ".(xml|css|jpe?g|png|gif|js)$">
Allow from all
</Files>
这导致界面中的图标显示为正方形。