.htaccess: RewriteEngine not allowed here

2020-01-28 05:27发布

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

8条回答
倾城 Initia
2楼-- · 2020-01-28 06:29

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

查看更多
劫难
3楼-- · 2020-01-28 06:31

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

查看更多
登录 后发表回答