As per security reasons, you should throw "404" for hidden directories, but apache is throwing 403 error code. I also checked few answers on stack overflow suggesting showing 404 page on 403 error code, but that is incorrect as we are still seeing 403 error code in Network. I want to show "404 Page Not Found for Hidden Directories". Is there any way to implement my scenario?? I will be ok for redirecting manually all hidden directories, but only with 404 error code.
Can I write Directory Access or anything that can work?
In image, I have tried to explain that I want server to respond with 404 instead of 403 Error codes.
2
Answers
I have tried enough of things like RewriteCond %{REQUEST_URI} !^/this-path-does-not-exist
but that didn't work for me... Later, I tried below code and that worked for me.
Thanks for the help!!
The best way to accomplish this is by altering the app that generates the 403.
If you are unable or unwilling to alter the code you can use .htacces to do an internal redirect to a non-existing location. The next line will redirect all requests to the archive directory to a non-existing location.
You will also have to add a RewriteCondition for the redirect to your front controller to prevent it from being redirected to your app.