Internal Server Error with .htaccess file Linux mint

0

I'm getting an HTTP 500 error Internal Server Error on linux mint, Apache server.

  

Server version: Apache / 2.4.7 (Ubuntu) / Server built: Apr 3 2014 12:20:28

.htaccess file

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1

What is the solution?

    
asked by anonymous 15.07.2014 / 04:52

1 answer

3

Module disabled

Your Apache2 probably does not have the Rewrite module enabled.

Type ls /etc/apache2/mods-available/ | grep rewrite and check if rewrite.load appears, if it means that the rewrite module is already installed and just enable it, enter the following:

a2enmod rewrite # Ativar o módulo
service apache2 restart # Reiniciar o servidor

If a rewrite.load did not appear when you gave ls /etc/apache2/mods-available/ | grep rewrite then mod_rewrite is not installed, look for how to install mod_rewrite on Linux mint (probably it should be the same as Ubuntu)


AllowOverride

Now we have to tell Apache2 to allow changes, through AllowOverride . Navigate to the Apache2 sites directory

cd /etc/apache2/sites-enabled/

type ls and see which site you want to edit, probably will be 000-default.conf . Assuming that this is the name:

mcedit 000-default.conf 

(Replace mcedit with your favorite editor such as nano, gedit, or geany). And edit all AllowOverride to AllowOverride All if you do not have any AllowOverride in the 000-default.conf edit the file /etc/apache2/apache2.conf and look for something like this:

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

And substitute this way:

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


Prevent the .htaccess from giving 500 error

You can prevent error 500 by changing your .htaccess file to only do the actions if the rewrite module is enabled, so change your .htaccess file like this:

# Checar se o modulo esta ativado
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?url=$1
</IfModule>
    
15.07.2014 / 10:43