Yes, there is.
TL;DR - respond 404 when 403
The error document may have to exist.
ErrorDocument 404 /404.html
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} 403
RewriteRule ^ - [R=404,L]
You would create a file 404.html
in the web root. NOTE: Doesn't work with deny from all
!
The Apache "Environment Variables" (!NOT! system env. vars)
A quote from these docs: https://httpd.apache.org/docs/2.4/env.html#preamble
Second, the Apache HTTP Server provides a mechanism for storing information in named variables that are also called environment variables
The access to %{ENV:variable}
is documented in:
REDIRECT_STATUS
Important quotes from these docs: https://httpd.apache.org/docs/2.4/custom-error.html#variables
REDIRECT_URL, REDIRECT_STATUS, and REDIRECT_QUERY_STRING are guaranteed to be set, and the other headers will be set only if they existed prior to the error condition
REDIRECT_ environment variables are created from the environment variables which existed prior to the redirect
I tried to find some sort of official list with Apache environment variables, but the best I could find was in the link above in:
I'm guessing it is implied that you know what it means when you're got this far
RewriteRule Flags [R=404,L]
R
- although it referres to "R|redirect", it doesn't have to mean Location
redirect:
The status code specified need not necessarily be a redirect (3xx) status code. However, if a status code is outside the redirect range (300-399) then the substitution string is dropped entirely, and rewriting is stopped as if the L were used.
2. L
referres to "L|last" - basically don't do anything else:
The [L] flag causes mod_rewrite
to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed.
BTW: this answer is according to the Apache 2.4 docs - Apache 2.4 was released in 2012