marți, 25 august 2009

Apache .htaccess: how to get rid of 'RewriteEngine not allowed here'

Apache error: RewriteEngine not allowed here

A friend of mine has changed his web hosting server, and since that moment one of it's web pages stopped showing. The page displayed instead was a generic page from the Apache web server, telling that there was an internal error and to check the logs.
Here's a line from the log:
[Tue Aug 25 17:07:39 2009] [alert] [client xx.xx.xx.xx] /usr/local/www/htdocs/.htaccess: RewriteEngine not allowed here
I tried to find the answer on the net, and after a short google search and after reading a little bit of apache docs, I found the answer.


How this appeared?

My friend's web site includes a file called .htaccess, which usually is populated with directives for the apache web server. In a default apache setup, this file is read on web page access, but only if the main configuration directives (from httpd.conf or vhost configuration file) allow this. This is specified by the 'AllowOverride AuthConfig' directive. Since I've seen the error, AllowOverride AuthConfig was 'On', so the .htaccess file was processed, but some of it's content is not permitted in this context.


How to allow RewriteEngine on directive in .htaccess

All I needed to do is to modify the apache configuration file referring to htdocs directory. In my case it was the virtual host definition file, but it may be the main apache config file, httpd.conf. I've changed the <directory> section from
<Directory /path/to/htdocs/>
Options +FollowSymLinks
AllowOverride AuthConfig
Order allow,deny
Allow from all
<Directory>
to
<Directory /path/to/htdocs/>
Options +FollowSymLinks
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
<Directory>

And it fixed the problem.

Ți-a plăcut această postare? Spune și altora!

Niciun comentariu:

Trimiteți un comentariu

Super ofertă la eMag!

Related Posts Plugin for WordPress, Blogger...