Error: RewriteEngine not allowed here


I started seeing this error on my website after enabling “pretty” Permalinks in WordPress and as a direct result of it, I got html Error 500 (Internal Server Error). If you get this error, it can be fixed by doing the following:

First check if the mod_rewrite module is loaded in apache. To do that, type the following command and you should get the output as shown below:

[rootuser@server ~]# cat /etc/httpd/conf/httpd.conf | grep rewrite
LoadModule rewrite_module modules/mod_rewrite.so

If you do not use virtual hosts, the next step refers to your httpd.conf file. If you do use virtual hosts, the next step refers to the vhost conf file.

Use your favorite editor to edit your vhost configuration file and check for all instances of the line that contains: ‘AllowOverride’ and see if it looks something like this:

AllowOverride Indexes FileInfo

The key here is ‘FileInfo’ if it isn’t there, add it. Now reload apache by issuing:

service httpd reload

If the RewriteEngine has been called in either your vhost file (or httpd.conf) file or the .htaccess file, you should now see the Internal Server Error go away.

This was a pretty weird error and I couldn’t find enough documentation about ‘FileInfo’ on the internet (not even on redhat’s website). I was lucky to come across one instance of it

On another note, it is safer not to use AllowOverride All as it increases the surface area for an attacker to compromise your website. Always only allow modules that are needed. Also, for better performance, always call and configure the modules in the apache configuration files rather than the .htaccess. htaccess is called at page load but the modules are loaded and configured when the webserver has been started.

Let me know if you have found a similar problems and if you have found a better way of fixing it!

Related posts:

  1. OCS 2007 Protocol Stack Error Event ID 14517 When Starting Services

, , ,

  1. No comments yet.
(will not be published)