我已经尝试了几种在网络上找到的变体,但是它似乎不起作用。我想阻止这些网址,因为它们出现在magento安全扫描中。
domain.com/index.php/rss/catalog/notifystock
domain.com/index.php/rss/catalog/review
domain.com/index.php/rss/order/new
domain.com/rss/catalog/notifystock
domain.com/rss/catalog/review
domain.com/rss/order/new
我尝试过的是:
location ^~ /rss/order/new {
deny all;
}
location ~ ^/index.php/?rss/ {
deny all;
}
location ~ ^/rss/ {
deny all;
}
location ~* ^/?(index.php?)?rss/(order/new|catalog/notifystock|catalog/review) { return 403; }
有些代码只能阻止没有index.php的url
一次查看规则...
location ^~ /rss/order/new { deny all; }
这将阻止你的问题中的第6个URI。
与^~
修饰符一起使用前缀位置是明确的,并且比正则表达式更有效。你可以使用以下命令阻止问题中的所有六个URI:
location ^~ /index.php/rss/catalog/notifystock { deny all; }
location ^~ /index.php/rss/catalog/review { deny all; }
location ^~ /index.php/rss/order/new { deny all; }
location ^~ /rss/catalog/notifystock { deny all; }
location ^~ /rss/catalog/review { deny all; }
location ^~ /rss/order/new { deny all; }
或者,对于更通用的规则,所有/rss/
URI都使用:
location ^~ /index.php/rss/ { deny all; }
location ^~ /rss/ { deny all; }
location ~ ^/index.php/?rss/ { deny all; }
这是一个正则表达式位置,需要放置在任何有冲突的正则表达式位置块上方(例如:)location ~ \.php
。有关详细信息,请参见此文档。
在?
之后的/
是不必要的,因为没有要求,以匹配URI等/index.phprss
。
如果在你的配置中放置足够高的位置,它将阻止你问题中的前三个URI。
location ~ ^/rss/ { deny all; }
这也是一个正则表达式位置,需要放置在任何有冲突的正则表达式位置块上方。
如果在你的配置中放置的位置足够高,它将阻止你问题中的最后三个URI。
与前面的规则一起,应该阻止问题中的所有URI,以及更多。
location ~* ^/?(index.php?)?rss/(order/new|catalog/notifystock|catalog/review) { return 403; }
这也是一个正则表达式位置,需要放置在任何有冲突的正则表达式位置块上方。
它不会匹配在你的问题前三的URI,因为它缺少/
之间.php
和rss
。
尝试:
location ~* ^(/index.php)/rss/(order/new|catalog/notifystock|catalog/review) { return 403; }
该规则需要放置在任何有冲突的正则表达式定位块(尤其是该location ~ \.php
块)上方。
位置〜^ / index.php /?rss / {拒绝全部;} location〜^ / rss / {拒绝全部;}这两个解决了我的问题(应放在位置〜\ .php上方)..谢谢!