简体   繁体   English

apache:通过 .htaccess 中的 RewriteRule 阻止请求

[英]apache: block request via RewriteRule in .htaccess

On my apache server I want to block every request containing the string test .在我的 apache 服务器上,我想阻止每个包含字符串test 的请求。

eg https://example.com/test/index.php例如https://example.com/test/index.php

This should be blocked via the .htaccess file, since the url contains test .这应该通过 .htaccess 文件阻止,因为 url 包含test

Can you please help me creating the regex statement?你能帮我创建正则表达式吗?

You can just use a simple rule at top of your .htaccess like this:您可以在 .htaccess 顶部使用一个简单的规则,如下所示:

RewriteEngine On

RewriteCond %{REQUEST_URI} /test/ [NC]
RewriteRule ^ - [F]

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

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