简体   繁体   English

使用.htaccess拒绝访问文件夹/文件

[英]Deny access to folder/file with .htaccess

i have this situation: 我有这种情况:

folderA/sub/sub/..../file.xml
folderB
folderC
...
.htaccess
index.php

I need deny access to all folderA, subdirectory and files, i put this rule to .htaccess but i can only deny access to folder, not the files inside 我需要拒绝访问所有folderA,子目录和文件,我将此规则设置为.htaccess,但我只能拒绝访问文件夹,而不能拒绝访问其中的文件

RewriteRule ^folderA(/|$) - [L,NC]

Thanks 谢谢

You can use: 您可以使用:

RewriteRule ^folderA(/|$) - [F,NC]

Using the [F] flag causes the server to return a 403 Forbidden status code to the client. 使用[F]标志会使服务器向客户端返回403 Forbidden状态代码。 While the same behavior can be accomplished using the Deny directive, this allows more flexibility in assigning a Forbidden status. 尽管可以使用Deny指令来实现相同的行为,但这在分配禁止状态方面具有更大的灵活性。

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

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