Error with .htaccess and mod_rewrite
Asked Answered
L

8

21

I'm trying to host a php based application with the following .htaccess values.

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php

RewriteEngine On
RewriteBase /easydeposit
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

However, I keep facing the following two errors,

[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

I'm not sure why this is happening. Any help is appreciated.

Libation answered 27/8, 2012 at 10:48 Comment(0)
I
57

If you have recently upgraded to a version of Apache greater than version 2.2, the authz_core error error might be coming from your httpd.conf or httpd-vhosts.conf file in the <Document> tags. mod_authz_core was introduced in Apache 2.3 and changed the way that access control is declared.

So, for example, instead of the 2.2 way of configuring <Directory>...

    <Directory "C:/wamp">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

Order and Allow directives have been replaced with the Require directive:

    <Directory "C:/wamp">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

Sources http://www.andrejfarkas.com/2012/06/fun-with-wamp-server-and-apache-2-4-2/ http://httpd.apache.org/docs/2.4/upgrading.html

Issacissachar answered 6/11, 2012 at 19:32 Comment(1)
Is there really no way to handle it without intruding into Apache's config file? The problem is that you must have root's privileges to do it....Kopans
T
4

This question/answer got me to the documentation for which I'm thankful, and the following was what solved it for me.

Previous .htaccess file:

# 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

This configuration was producing errors like:

[Thu Dec 08 10:29:20.347782 2016] [access_compat:error] [pid 2244:tid 15876] [client 93.93.93.93:49340] AH01797: client denied by server configuration: C:/path/to/index.php

updated for 2.4 configuration

# 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
Tetrachord answered 8/12, 2016 at 16:52 Comment(0)
U
2

I doubt this has anything to do with your htaccess file. The errors are thrown by mod_access_compat, which provides the Allow, Deny, Order, and Satisfy directives. Somewhere, you probably have your allow's and deny's configured wrong. As for the .htaccess error at the end, it's from mod_authz_core, so there may be something upstream that blocks access to .htaccess files outright.

Unreeve answered 27/8, 2012 at 17:16 Comment(0)
I
0

Are you sure that your are allowed to override Options in your .htaccess file? check main apache config file for this

Inbreathe answered 27/8, 2012 at 10:53 Comment(1)
I have enabled override options in my httpd.conf file.Libation
S
0
Options +FollowSymLinks
Options -Indexes

on many shared hosting the above code often the main problems

Smallman answered 27/8, 2012 at 11:2 Comment(1)
I tried it without the above code too, but does not seem to make any difference...Libation
C
0

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

Cigarillo answered 27/8, 2012 at 11:8 Comment(1)
Yes absolutely. I made sure to change the user/group permissions for the directoryLibation
K
0

Another example, rewrite from:

www.yoursite.com/script.php?product=123 

to

www.yoursite.com/cat/product/123/

using

RewriteRule cat/(.*)/(.*)/$ /script.php?$1=$2

http://w3webtutorial.blogspot.com/2013/11/htaccess-and-modrewrite-in-your-php.html

Kiel answered 18/11, 2013 at 5:51 Comment(0)
G
0

For me, there was an .htaccess file in the wp-config folder that had these entries

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

That caused icons in the interface to show up as squares.

Goldeneye answered 24/2, 2019 at 19:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.