[英]Apache: deny access to folder but allow with mod-rewrite
I want to prevent access to a folder /workspace/test
我想阻止访问文件夹
/workspace/test
I've done this with the following piece of code我已经使用以下代码完成了此操作
RewriteRule ^(workspace/test) / [R=404,L,NC]
Now I have a second rewrite rule现在我有第二个重写规则
RewriteRule ^news\/(.*)$ workspace/test/news.php [L,NC]
The problem it that I get a 404
because of the first rewrite rule.由于第一个重写规则,我得到
404
的问题。
Is it possible deny access to files if the user enters it in the URL but allow access to these files if I do it with a RewriteRule
?如果用户在 URL 中输入文件,是否可以拒绝访问文件,但如果我使用
RewriteRule
进行访问,则允许访问这些文件?
Use THE_REQUEST
variable:使用
THE_REQUEST
变量:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /workspace/test [NC]
RewriteRule ^workspace/test - [R=404,L]
RewriteRule ^news/(.*)$ workspace/test/news.php [L,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.