Search code examples
apache.htaccessmod-rewrite

Apache2 gives 500 Internal Server Error


I've problem with my server. It gives 500 Internal Server Error.

My domain.conf looks like this under sites-available:

<VirtualHost *:80>
        ServerName domain.com

        ServerAdmin [email protected]
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

And my apache2.conf looks like this:

<Directory />
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>
<Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

And my .htaccess file looks like this:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.domain\.com|188\.166\.104\.193)$ [NC]
RewriteRule (.*) http://domain.com/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

RewriteRule ^([^/]+)/$ $1.php [L]

RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php [L]

I don't understand where the problem is. It gives 500 Interval Server Error.

Can you please help me about that?

Best regards.


Solution

  • Based on your log:

    Try this:

    a2enmod expires
    

    or

    ln -s /etc/apache2/mods-available/expires.load /etc/apache2/mods-enabled/
    

    Then

    service apache2 restart