通过htaccess阻止对某个文件夹的外部http请求

时间:2012-01-04 10:06:59

标签: apache .htaccess

我想阻止指向某个文件夹的所有外部http请求,并允许所有内部(来自服务器本身)的http请求。

这是我的.htaccess文件

# Denied access folders
RewriteRule ^resources* - [F]
RewriteRule ^assets* - [F]

感谢您的帮助:)

2 个答案:

答案 0 :(得分:2)

恕我直言,在每个文件夹中放置一个适当的.htaccess文件会更容易,并避免使用mod_rewrite

#
# Restrict access by IP address
#
Order Allow,Deny 
Allow from 127.           # localhost

您可以根据需要添加任意数量的Allow规则。

答案 1 :(得分:0)

确保此目录只能由此域中的其他程序访问

SetEnvIfNoCase Referer my-domain.com internal

命令拒绝,允许 拒绝所有人 允许来自env = internal