繁体   English   中英

.htaccess和mod_rewrite出错

[英]Error with .htaccess and mod_rewrite

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

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

如果您最近升级到版本大于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

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

上一个.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

我怀疑这与你的htaccess文件有什么关系。 mod_access_compat抛出错误,它提供AllowDenyOrderSatisfy指令。 在某个地方,你可能有你的允许和拒绝配置错误。 至于最后的.htaccess错误,它来自mod_authz_core ,因此上游可能会阻止对.htaccess文件的访问。

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

Options +FollowSymLinks
Options -Indexes

关于许多共享托管上面的代码往往是主要问题

你绝对相信apache用户(可能是_www)可以访问目录( /home/abc/opt/apache/htdocs/xyz/ )吗?

另一个例子,改写自:

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

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM