apache - Apache - htaccess 如何阻止 GET 请求 URL?
问题描述
我想阻止对 URL 的所有访问,例如:
/services/login.php?action=clientlogin&user=K8YcWKOZ&password=UzTXhhn5
/services/login.php?action=clientlogin&user=m4eQ97We&password=xxAz6I8Z
基本上我想给所有包含 403 ERROR 的 URL action
:&user
和&password
我已经测试过:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /services/login.php\?action=clientlogin&user=([^\s&]+)
RewriteRule .* - [F]
RewriteEngine On
RewriteCond %{QUERY_STRING} ^.*(user|password).* [NC]
RewriteRule ^(.*)$ - [F]
和:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /services/login.php\?action=clientlogin&user=([^\s&]+)
RewriteRule .* - [F,L]
RewriteCond %{QUERY_STRING} ^.*(user|password).* [NC]
RewriteRule ^(.*)$ - [F,L]
但它无法阻止访问。
如何阻止通过 htaccess 文件访问此 URL?
解决方案
你可以试试这个规则:
RewriteEngine On
RewriteCond %{THE_REQUEST} \?action=[^&\s]*&user=[^\s&]*&password=[^&\s]* [NC]
RewriteRule .* - [F,L]
推荐阅读
- python - 将 BeautifulSoup 对象插入另一个对象
- android - 使用 GLES20 覆盖纹理并应用旋转
- c# - 如何从单独的脚本调用函数并且所述脚本在多个游戏对象上激活?
- python - Django 频道页面卡在加载中
- php - 如何在mpdf的页面中心显示文本
- python - 在 groupby 操作后将 Dataframe pyspark 转换为字典
- eclipse - Eclipse:Java Content Assist Advanced 选项卡为空
- clob - 无法在 Mulesoft 中序列化对象类型 Clob
- java - dockerized时Spring Boot Redis错误,但不是maven run
- node.js - NestJS - 如何在自定义验证中从猫鼬模式调用服务方法