21

我正在尝试使用以下 .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

我不确定为什么会这样。任何帮助表示赞赏。

4

8 回答 8

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>

OrderAllow指令已替换为Require指令:

    <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

于 2012-11-06T19:32:23.507 回答
4

这个问题/答案让我得到了我很感激的文档,以下是为我解决的问题。

上一个.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
于 2016-12-08T16:52:24.563 回答
2

我怀疑这与您的 htaccess 文件有关。错误由mod_access_compat引发,它提供AllowDenyOrderSatisfy指令。在某个地方,您可能将允许和拒绝配置错误。至于最后的 .htaccess 错误,它来自mod_authz_core,因此上游可能有一些东西完全阻止了对 .htaccess 文件的访问。

于 2012-08-27T17:16:43.533 回答
0

您确定允许您覆盖 .htaccess 文件中的选项吗?检查主apache配置文件

于 2012-08-27T10:53:50.977 回答
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

于 2013-11-18T05:51:21.453 回答
0

And you are absolutely sure that the apache user (probably _www) has access to the directory (/home/abc/opt/apache/htdocs/xyz/)?

于 2012-08-27T11:08:46.203 回答
0
Options +FollowSymLinks
Options -Indexes

在许多共享主机上,上面的代码通常是主要问题

于 2012-08-27T11:02:14.563 回答
0

对我来说,wp-config 文件夹中有一个 .htaccess 文件,其中包含这些条目

Order deny,allow
Deny from all
<Files ~ ".(xml|css|jpe?g|png|gif|js)$">
Allow from all
</Files>

这导致界面中的图标显示为正方形。

于 2019-02-24T19:40:37.620 回答