Let's say we have a password.txt in a webdirectory that must not be leaked. Is it secure to use a RewriteRule like this?
RewriteRule "^password.txt?*" "404.html"
I tried to do something fishy like domain.com/somefile/../password.txt
, or using "password%2Etxt", and it still redirected to 404. Is there anything else I have to worry about? If it's hackable, what's the hack? My understanding of the URL specification is that this is not possible. But, I'm handwaving a bit.
Will the input to a rewriterule always be something guaranteed by the URL specification, or will they relax the requirements a bit the way css can be relaxed. If not, is the URL specification itself safe against this redirection?
I can use .htaccess to simply ban the file, but then RewriteRule "sldmfklwmefwk.txt" "password.txt"
doesn't work either. I want "sldmfklwmefwk.txt" to be allowed, but "password.txt" is banned, and any other attempts to access "password.txt" being blocked without accessing it via "sldmfklwmefwk.txt".