My .htaccess file causes an internal error when I add a slash to a php file in the folder that the .htaccess file is in. Why does this happen and how could I prevent this error from happening?
I would like the page where the internal error is being caused to display the php file (instead of a redirect as some users have the php file with a / at the end cached)
Here's my .htaccess file:
RewriteEngine on
RewriteBase %{REQUEST_URI} ^(.*)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
ErrorDocument 404 /content/errors/404.php
ErrorDocument 403 /content/errors/403.php
ErrorDocument 500 /content/errors/500.php
Examples:
https://mywebsite.com/folder/file
✔️ works!
https://mywebsite.com/folder/file.php
✔️ works!
https://mywebsite.com/folder/file/
❌ 500 internal error