Apache config: Return 404 for single <Location>
The only solution "without any modules", is to not have the resource exist. If the location doesn't exist, then it Apache will return a 404.
Otherwise, you will need to use mod_alias or mod_rewrite. mod_alias is the simpler and more efficient solution:
Redirect 404 /your/url/path
You use this inside your vhost, there is no need to put it in a Location block.
You can also use the RedirectMatch
directive if you don't want to match URLs below /your/url/path
:
RedirectMatch 404 ^/your/url/path$
This and more can be read in the mod_alias documentation
Apparently you can use a RewriteRule
for this (make sure your RewriteEngine is enabled):
RewriteRule ^/forbidden_ /nonexistent [L]
Got this information from "return 404 for specific url?" in the Apache mailing list archives.