Forum Moderators: phranque
I have this code, which I put into site root, and I want to hide all folders inside site root, so I am returning 403 for them. The questions are:
1) I need this code to be applied only for internal directories and files inside them, but not for site root directory.
2) How to return 404 error code instead of 403?
RewriteEngine on# if it exists as a directory
RewriteCond %{REQUEST_FILENAME} -d [OR]
# then send forbidden (403)
RewriteRule (.*) - [F]
# if requested subdirectory exists
RewriteCond %{DOCUMENT_ROOT}/$1 -d
# if URL-path indicates a subdirectory (plus any additional filenames, etc.)
RewriteRule ^(([^/]+/)+) /some-filepath-that-does-not-exist-so-as-to-force-a-404 [L]
Jim
[edited by: jdMorgan at 6:08 pm (utc) on Aug. 26, 2008]
I have .htaccess in root site dir with these lines:
RewriteEngine on
RewriteRule ^(([^/]+/)+) /page-not-found-404 [L]
How can I limit this rules to not apply when I ask for subdomains (without putting .htaccess with rewriteengine off" in each subdirectory), but only make it works for directories?
Thanks in advance!