I have this .htacess on my server to redirect example/test -> example/test.php.
ErrorDocument 404 http://example.net/404
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [L]
It works for basic url but when I request "example/fakefolder/test" it return a 500 error.
And i have nothing in the logs saying i have a 500 error.
The problem you're seeing is that the
-fcheck when paired with%{REQUEST_FILENAME}is sort of a "fuzzy" check. It includes pathinfo style matching, which means if you have a file/script.phpand the request is/script/blahblah, the condition%{REQUEST_FILENAME}.php -factually returns true because it fuzzy matches:/script.php/blahblah, which exists as a file, via pathinfo style URL.You need to be explicit about your path and include the possible
/.