I am using .htaccess to add .php to files requested, so the request “/example” goes to “/example.php”
However, when “/example.php” doesn’t exist, I get an Internal Server Error instead of a 404. How can I get it to work with 404, not 500?
RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.+)$ $1.php
You can try replacing:
with:
So that the rule only gets applied if there’s a file that ends with php that exists.