.htaccess returns error 500 instead of 404

1

My .htaccess file seems to be ok, but if we try to access a page that does not exist, instead of getting the 404 error response, I get the 500 error response.

This is the current code:

RewriteEngine On

# Remove o www e força o https
# funciona muito bem
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule (.*) https://%1/$1 [R=301,L]

# Deveria carregar as páginas amigáveis de erros, mas não funciona!!!!
RewriteBase /
RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ /e404.php [L]
RewriteCond %{REQUEST_URI} ^/500/$
RewriteRule ^(.*)$ /e500.php [L]

# Permite carregar as páginas sem a extensão .php, também está OK.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
    
asked by anonymous 17.03.2017 / 16:01

1 answer

1

I solved the problem by switching

# Permite carregar as páginas sem a extensão .php, também está OK.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]

by

#permite carregar as páginas sem a extensão .php
RewriteRule ^([^\.]+)$ /$1.php [NC,L]  
    
22.03.2017 / 20:46