39

I uploaded the .htaccess to the server and received an Error 500 (Internal Server Error).

And in the error log I had the following error:

.../.htaccess: RewriteEngine not allowed here

But mod_rewrite.so is enabled.

So, do I need to change

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

to

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

in the /etc/httpd/conf/httpd.conf file?

Or could it be something else? The .htaccess file should be okay, because it works perfectly fine on my localhost. I just don't want to screw anything up.

Here's part of my .htaccess file:

Options All -Indexes

Options +FollowSymLinks

RewriteEngine On
  • Yes, it's all about `AllowOverride` directive. Not necessary `AllowOverride All` .. but at least `AllowOverride FileInfo`. Details: http://httpd.apache.org/docs/current/mod/core.html#allowoverride – LazyOne Aug 09 '11 at 11:40
  • is that's all the error log shows? – linuxeasy Aug 09 '11 at 11:40
  • @linuxeasy Yes. The path and .htaccess: RewriteEngine not allowed here. That's it. –  Aug 09 '11 at 11:42

8 Answers8

61

minimum configuration for your .htaccess to work:

AllowOverride FileInfo Options

allowing all configuration will work as well:

AllowOverride All
Jacek Kaniuk
  • 5,229
  • 26
  • 28
  • 1
    AllowOverride All wroked but AllowOverride FileInfo Options doesn't, wp-includes/.htaccess: deny not allowed here – Sérgio Jun 07 '16 at 18:42
  • @Jacek Kaniuk How to allow htaccess in 1and1 – Ilyas karim Oct 17 '16 at 12:09
  • 3
    `AllowOverride` controls the _type_ of directives that can be used in `.htaccess`. So whether `AllowOverride FileInfo Options` is sufficient is entirely dependent on what directives you are using. `FileInfo` is required for mod_rewrite, `FileInfo Options` is required for the `.htaccess` file in the question. To use `Deny` in `.htaccess` you also need to include the `Limit` directive-type. @Sérgio But most just stick with `All` for "ease of use". – MrWhite Apr 06 '18 at 00:38
  • 2
    However, contrary to what this answer implies, you should never set anything other than `AllowOverride None` in the `` container (as stated in the question) - which refers to the _server root_ - the [Apache docs](https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride) specifically warn against doing this "for security and performance reasons". Instead, this should be set for the specific directory that contains the `.htaccess` file, such as the DOCUMENT_ROOT, as mentioned in @anubhava's answer. – MrWhite Apr 06 '18 at 00:44
9

Let's say your DOCUMENT_ROOT is /home/foo/web then have this config in your httpd.conf file:

<Directory "/home/foo/web">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

This should take care of RewriteEngine is not allowed error you're getting.

anubhava
  • 761,203
  • 64
  • 569
  • 643
4

Just an idea, this happened to me, and I've lost a lot of time trying to solve it.

If you have a directory like d:/web/my-sites/some-site/

And you place the .htaccess on d:/web/my-sites/some-site/.htaccess (where it supposed to be).

If you have ANY .htaccess files before this directory, Apache reads that files, and blocks the execution of the entire path, producing an internal server error.

I.E.: You have d:/web/my-sites/.htaccess

Keith Hughitt
  • 4,860
  • 5
  • 49
  • 54
  • 1
    I just found a solution, http://stackoverflow.com/questions/32084190/rewriteengine-not-allowed-here-caused-by-htaccess-in-parent-directory – benck Oct 24 '16 at 10:29
  • This should still depends on how/where you have `AllowOverride` (and `AllowOverrideList` on Apache 2.4+) set. And possibly the Apache version, since the default value of the `AllowOverride` directive changed between Apache 2.2 and 2.4. – MrWhite Apr 06 '18 at 00:15
3

In httpd version 2.4 (2.4.3 and 2.4.4), take a look at /etc/httpd/conf.d/wordpress.conf There is one entry for: ....

Change: "AllowOverride Options" to "AllowOverride All"

in wordpress.conf also in addition to changing httpd.conf. Restart the http server before the changes will take effect.

P. Sharma
  • 31
  • 1
0

Try to change username.conf file on Mac under /etc/apache2/users/username.conf to

<Directory "/Users/akyoo/Sites/">
   AllowOverride All
   Options Indexes MultiViews FollowSymLinks
   Require all granted
</Directory>

My .htaccess file looks like this

#Allow from all
Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

This works fine for me. Solution for Ubuntu users

MrWhite
  • 43,179
  • 8
  • 60
  • 84
Gpak
  • 3,342
  • 2
  • 21
  • 19
  • Just to add, only enable `MultiViews` if you specifically need it. If you are using mod_rewrite, as in this example, then you probably don't - and this can potentially result in unexpected conflicts. – MrWhite Apr 06 '18 at 00:52
0

Also, just make sure you are editing the correct config file. I had created a file under /etc/apache2/users/USERNAME.conf but was editing /etc/apache2/httpd.conf.

Removing the USERNAME.conf file worked.

Aaron Lifshin
  • 225
  • 1
  • 11
0

I was getting this type of error from the Google Cloud instance after checking the logs from the /var/log/apache2/error.log

.htaccess: RewriteEngine not allowed here

To get rid of the above error & 500 Internal Server Error, follow these simple steps

sudo nano /etc/apache2/apache2.conf

Then add these snippets of lines

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

After you’ve made that change, make sure to restart the server:

sudo service apache2 restart

This worked for me in getting rid of 500 Internal Server Error hosted on Google Cloud instance

Nɪsʜᴀɴᴛʜ ॐ
  • 2,756
  • 4
  • 33
  • 57
-4

you could use something like this in your .htaccess file:

RewriteEngine on
RewriteCond $1 !^(index\.php|html|test)
RewriteRule ^(.*)$ /index.php/$1 [L]

this code simply means, that anything not pointing to index.php or html or test should be directed to index.php!

Hope this is helpful!

linuxeasy
  • 6,269
  • 7
  • 33
  • 40
  • Oh, I think I will use that thanks! But I don't think that gets rid of the problem that RewriteEngine is not allowed. –  Aug 09 '11 at 11:41