6

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?

JD Isaacks
  • 855
  • 5
  • 14
  • 24

4 Answers4

7

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

Gerald Combs
  • 6,331
  • 23
  • 35
  • So simple! Thanks :-) In case it helps anyone else, I customised my message too by adding a line before it with: `ErrorDocument 404 "

    My message

    "`
    – Highly Irregular Jul 30 '18 at 03:24
5

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]
Nathan J.B.
  • 151
  • 1
  • 6
1

Simple:

RewriteEngine On
Redirect 404

And check you have on the Apache configuration the AllowOverride sentence with FileInfo or All to allow this type of .htaccess.

NetVicious
  • 462
  • 5
  • 17
0

...what about actually removing it (or renaming it, or moving it away...)?

What's the point anyway of having it there if you want to make it not accessible at all?

Massimo
  • 68,714
  • 56
  • 196
  • 319
  • 1
    I want it accessible to one domain and not another. I have more than one domain pointing to the same server. Most of the pages slightly adjust based on domain (logo, description, etc.) Some resources should appear to only be on 1 domain though. – JD Isaacks May 19 '11 at 20:28