简体   繁体   English

htaccess防止直接访问路径并被另一个覆盖

[英]htaccess prevent direct access to path and override with another

There are two parts to my question... 我的问题有两个部分...

A. What .htaccess should I place in a root folder, in order to prevent ALL DIRECT access to ALL sub-folders & files 答:我应该在根文件夹中放置什么.htaccess,以防止对所有子文件夹和文件的所有直接访问

B. After doing that, is there a way to place another .htaccess file inside a specific folder (within the root folder) in order to override the first root .htaccess rule B.之后,是否有办法将另一个.htaccess文件放在特定文件夹(位于根文件夹内)中,以便覆盖第一个根.htaccess规则

in example : 例如:

I would like to prevent all direct access to the blog sub-directories 我想防止所有直接访问blog子目录的行为

blog/posts
blog/files

with a single .htaccess file placed in the root directory 在根目录中放置一个.htaccess文件

But I still want the following to be accessible 但是我仍然希望以下内容可以访问

blog/js
blog/css

using a specific .htacess file to be placed within each of those 使用特定的.htacess文件放置在每个文件中

Thanks! 谢谢!

update - I actually found an answer to A (deny from all), but still how can I override the deny from all placed in the root folder, with a specific .htaccess in a specific sub-folder 更新-我实际上找到了对A(全部拒绝)的答案,但是仍然如何在特定的子文件夹中使用特定的.htaccess覆盖根文件夹中所有拒绝的内容

You can place this directive in /blog/.htaccess to deny all files and folders first: 您可以将此指令放在/blog/.htaccess以首先拒绝所有文件和文件夹:

deny from all

Then inside the folders you want to allow access ie blog/css or blog/js , create a .htaccess file with this directive: 然后在您要允许访问的文件夹(即blog/cssblog/js ,使用以下指令创建.htaccess文件:

allow from all

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM