我想使用以下内容限制对某个目录及其所有子目录和文件的访问:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)ht-test(.*)$ - [NC,R=401,L]
</IfModule>它在index.html上工作得很好,但在test.php上就不行。我不知道发生了什么事。^(.*)ht-test(.*)$不应该匹配URL中包含它的任何内容吗?用this site对它进行了测试,似乎可以同时使用php和html。
我也尝试过使用<Directory "./ht-test"> Deny from All </Directory>,但无论我输入什么,都会出现内部服务器错误。
以下是我的测试:
发布于 2020-10-13 09:10:14
最后,我想通了。在Plesk中有一个如何服务PHP的设置(在域名的Hosting Settings下)
我使用的是FPM application served by nginx,它为PHP文件注册.htaccess指令。Apparently, for performance reasons
在将其更改为“由Apache提供服务”后,它按预期工作。

出于某些原因,我认为禁用nginx代理模式会完全禁用它作为服务。
https://stackoverflow.com/questions/64311155
复制相似问题