阻止访问到Web子目录的.htaccess [英] Block access to a web subdirectory with .htaccess

查看:128
本文介绍了阻止访问到Web子目录的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目录:

/root/
/root/directory1/
/root/directory2/

如果在的.htaccess 文件位于内根, 我该如何拒绝访问 directory1中 同时允许访问 directory2

If the .htaccess file is located inside root, How do I deny access to directory1 while allowing access to directory2

请您通过被precise帮助吗?我是一个总的初学者,办公室的职业是在度假:)可能提前感谢!

Could you please help by being precise? I am a total beginner, the office's pro is on vacation :) May thanks in advance!

推荐答案

TL;博士的版本低于但它是更好地学习如何钓鱼。因此RTFM这样一个人知道该怎么做总是问的答案吧。

The tl;dr version is below however it is better to learn how to fish. Thus rtfm so one knows what to do instead of always asking for the answer.

我建议就如何使用的.htaccess 阻止访问以资源阅读了以及如何否认目录索引。另外一个人需要确保.htaccess文件不能直接accessable 与绝对URL。

I suggest reading up on how to use .htaccess to block access to a resource and how to deny directory index. Also one needs to ensure that .htaccess files cannot be directly accessable with an absolute url.

所以你的.htaccess看起来应该像下面这样:

Therefore your .htaccess should look something like the following:

#/root/.htaccess - override any .htaccess in /directory1 and /directory2

# prevent listing of directory contents
Options -Indexes

# block .htaccess from being read
<Files .htaccess>
order allow,deny
deny from all
</Files>

<Directory "/directory1">
 order deny,allow
 deny from all
</Directory>

这篇关于阻止访问到Web子目录的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆