Display 404 if Rewrite fails

Hi,

I have the following rewrite rule in my .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.html

It basically rewrites example.com/page-name to example.com/page-name.html, where page-name.html is a physical file. This works fine for existing files but when I try an URL for a non-existing file such as example.com/page-x, it displays a 500 Internal Server Error. I want to display a 404 Page Not Found error, instead. Is that possible?

Thanks for any ideas.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.