htaccess rewriteRule restrict access to one particular folder problem
I have problem with getting the folder inc restricted.
It is only the inc folder in the root directory and not the inc folders higher up the hierarchy
Problems are:
IE will start a download/open dialog and
FF displays an include file
I don´t have this problem with the images folder which is also in the root directory.
What logic could I use to prevent this, please?
Options +FollowSymlinks
RewriteEngine On
Options All -Indexes
IndexIgnore *
# RewriteRule ^inc($|/) - [R=403,L]
RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?taxi-bel\.nl [NC]
RewriteRule \.(gif|png|jpg|css|js)$ - [F,NC,L]
#######################################################################
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
####################################################################### RewriteCond %{HTTP_HOST} ^www.(.) [NC] RewriteRule ^(.)$ http://%1/$1 [R=301,NC,L]
Edit because
I solved the problem by adding this rule DirectoryInde开发者_JAVA百科x index.php
and to place an index.php in the inc folder which points to an error file, - or you can make it the error page itself -, and problem solved!
The rule you commented out can do that:
RewriteRule ^inc($|/) - [F,L]
And I would rather send a 404 than a 403. But this requires Apache 2.
If you only want to disallow accessing the inc
folder and its contents via the webserver ayou can simply put a .htaccess
file in the inc
folder itself and disallow all accesses from outside.
Order deny, allow
deny from all
精彩评论