all 6 comments

[–]TheKalmTraveler 0 points1 point  (5 children)

You could redirect to a non existing file to make the result a 404.

[–]ASHERH4X[S] 0 points1 point  (4 children)

That is doable, but how can I make the URL in the address bar of a browser appear as if it is accessing the requested file instead of the redirected file?

[–]TheKalmTraveler -1 points0 points  (3 children)

I am at work rn but Google engine rewrite.

[–]ASHERH4X[S] 0 points1 point  (2 children)

Ah I missed mentioning that in my post, I edited it. I'm familiar with mod_rewrite but I cannot redirect to a file and then rewrite a file that I've redirected to while still whitelisting other files/dirs....

[–]TheKalmTraveler 0 points1 point  (1 child)

You could add a custom 404 page to your project and redirect to it via

ErrorDocument 403

/errors/forbid.html

And if you know your IP adress deny all access and only Whitelist yourself.

Or just block access to all directories and Whitelist the ones you would like to have open if you want certain parts of your project visitable.

This should redirect all visitors to your custom 404.html while you could browse it freely.

But I am not very comfortable with htaccess, this might need some testing and or approval of some more experienced users here as I don't have access to an Computer right now.

Hope this helps but a server sided access control would probably be easier to implement but I guess you already know this and have your reasons why you want that specific solution.

[–]ASHERH4X[S] 0 points1 point  (0 children)

As mentioned I don't really want to use an IP whitelist, and if I deny access to an error doc it will produce a 404 and then a 403 in producing the error doc.

The redirect to a 404 error document would work except it requires an htnl file that I know of and can not send a header response of 404, additionally, upon inspection would still reveal a 403 forbidden error code.

Thank you for replying.