How do I do this in my .htaccess file for a specific directory in my document root?:
Seems like it would be simple. This works but throws a 403 not a 404:
deny from all
You just need to add a few commands to . htaccess to make it happen. For example, deny from all is a command that will allow you to apply access restrictions to your site.
Why not create a custom error page?
deny from all
ErrorDocument 403 /error/404.html
The server will always want to throw a 403 error if someone is not authorized to view the page and that's what you're trying to do. However, you can change the ErrorDocument for error 403 to show an HTML page that says it's a 404 error.
My example has a folder in the root directory named error
and an html file in it named 404.html
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With