I'm using LAMP hosting on AwardSpace.com.
I have a private folder foobar and when a page </foobar> is requested, it redirects with a 301 to </foobar/> (, allowing pentesters to tell that the folder exists). This is so even after adding a htaccess file:
rewriteengine on
rewriterule foobar$ testpage.php
I believe the server itself is doing the redirection regardless of my hosting content.
How can the redirect be prevented?
(For undocumented behavior,) To prevent folders being 301ed‑with‑slash‑appended, you can add a redirect flag to the rewrite rule:
rewriterule foobar$ /testpage.php [r]
With that, no one will know that foobar is actually a folder.
r can be appended with =x where x is a value that doesn't cause redirection. This can be 305. This can be 510. This can be 200. In such cases the 3rd argument is ignored (cf):
rewriterule foobar$ yadadadaada [r=200]
errordocument 200 "test page"
, or:
errordocument 200 /testpage.php