Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 为htaccess中要阻止的链接中的任何数字创建通配符_.htaccess_Wildcard - Fatal编程技术网

.htaccess 为htaccess中要阻止的链接中的任何数字创建通配符

.htaccess 为htaccess中要阻止的链接中的任何数字创建通配符,.htaccess,wildcard,.htaccess,Wildcard,有人在我的网站上尝试一些坏东西,我厌倦了阻止他使用的IP。所以我想阻止他一起执行代码,并将任何此类尝试重定向到本地服务器。为此,我在.htaccess中使用以下条件: RewriteCond%{QUERY\u STRING}^id=http://213.246.61.125:2082/index.html$[NC] 重写规则页面.phphttp://127.0.0.1/index.php? [NS,S,L] 现在,我们正在从许多不同的IP上尝试这一点,index.html也位于这些IP上。所以我

有人在我的网站上尝试一些坏东西,我厌倦了阻止他使用的IP。所以我想阻止他一起执行代码,并将任何此类尝试重定向到本地服务器。为此,我在
.htaccess中使用以下条件:

RewriteCond%{QUERY\u STRING}^id=http://213.246.61.125:2082/index.html$[NC]
重写规则页面.phphttp://127.0.0.1/index.php? [NS,S,L]

现在,我们正在从许多不同的IP上尝试这一点,index.html也位于这些IP上。所以我想做一个通配符,这样无论index.html之前的IP是什么,尝试它的人总是被重定向到他的本地服务器。 我不知道该怎么做。我不能像您在其他地方那样使用IP通配符
(34.5.*.
,因为这是一个链接。因此,我假设我必须使用以下内容:

RewriteCond%{QUERY_STRING}^id=http://([0-9])([0-9])([0-9])([0-9]):2082/index.html$[NC]
重写规则页面.phphttp://127.0.0.1/index.php? [NS,S,L]


但是,上面的说法是不对的,但我不知道如何对任何数字组合进行调整。也许有人可以帮忙?

您应该在
[0-9]
字符范围后加一个加号,因为您想匹配一个或多个字符。还要注意

  • 正则表达式中的点应该用反斜杠引用。否则,它们将匹配任何字符
  • RewriteCond
    中的括号是不必要的
  • RewriteRule
    中的
    NS
    S
    标志可能是不必要的
我会尝试以下方法:

RewriteCond %{QUERY_STRING} ^id=http://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:2082/index\.html$ [NC]
RewriteRule page\.php http://127.0.0.1/index.php [L]

谢谢你的回复!我已经使用了上面的示例,但是我决定添加一个.*来匹配.html之后的任何内容,因为我注意到他们以问号结束了他们的尝试。这就是我使用的语法:
RewriteCond%{QUERY\u STRING}^id=http://[0-9]+\[0-9]+\[0-9]+\[0-9]+\[0-9]+:2082/index\.html.$[NC]RewriteRule page\.phphttp://127.0.0.1/index.php [五十] 
现在,任何带有
http://*.*.*:2082/index.html?
http://*.*.*.*:2082/index.html
的请求都会重定向到本地服务器。我想我很高兴这样走,再次感谢!