When I try to remove my PHP extensions from all my files using my .htaccess file on my Apache server, everything works great. The extensions are removed, and everything looks much better.
However, I'm having one small issue: when I would normally go to a page such as ./nonexistent.php
, I would get a 404 error. But, when I rewrite my URLs, and I go to ./nonexistent
, I instead get a 500 Internal Server Error
.
Ideally, I would like to simply redirect my user to a custom 'Page Not Found' page, but I can't currently find a way to do this.
Here's the code I'm using:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php
I've tried setting: ErrorDocument 500 /nope
, however, this doesn't seem to have an effect either.
So, to conclude, does anyone know how to rewrite extensions, while maintaining the same functioning of the 'Page Not Found' system that is the default?