How to throw a 404 error from htaccess?

Everything I find seems to be about created a custom 404 page.

That is not what I am trying to do.

If I want to block access to a page I can do this in htaccess:

RewriteRule pattern - [F]

However, "Forbidden" hints that the page does exists. I want the page to appear to not even exist. So I would like to give a 404 error instead of a 403. Then have it render whatever 404 page would render if the resource really wasn't there.

How can I do that?


The documentation and AskApache suggest that you can simply use Redirect 404.


Redirect 404 will work but will execute across all domains pointing to your vhost. Since you're using multiple domains, you'll want to use RewriteRule:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^microsite\.someotherexample\.net$
RewriteRule ^path/to/page/?$ - [R=404,NC,L]