.htaccess returns error 500 instead of 404

Asked

Viewed 679 times

-1

My file. htaccess seems to be ok, but if we try to access a page that doesn’t exist, instead of getting the 404 error reply, I get the 500 error reply.

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]

1 answer

0


I solved the problem by changing

# 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]

for

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.