本文介绍了阻止通过htaccess的一个特定的URL。不能那么难的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

难以置信,我无法找到解决我的新手问题。也许我用错了搜索字词? (htaccess的块URL,htaccess的块单个URL,阻止特定的URL htaccess的,...)

我只是有这个网址的页面:http://www.gute-mathe-fragen.de/40224/redaktionelle-frage-wann-antwort-wann-lediglich-kommentar

我想阻止这个URL,因为不同的机器人(和人类)造成了超过4000的点击一小时之内。

我试过内的htaccess的follwing:

 的RewriteCond%{REQUEST_URI} ^ 40224 \ / $ [NC]
。重写规则*  -  [F]
 

没有成功。

哪位亲可以帮助初学者迅速? THX;)

解决方案

当有人请求:

<$p$p><$c$c>http://www.gute-mathe-fragen.de/40224/redaktionelle-frage-wann-antwort-wann-lediglich-kommentar

%{REQUEST_URI} 变量是:

  / 40224 / redaktionelle-frage-WANN-antwort-WANN-lediglich,提出您的
 

和正则表达式 ^ 40224 \ / $ 永远不会匹配。事实上,你甚至不需要一个的RewriteCond 在这种情况下,只要把该模式的规则:

 重写规则^ 40224 / redaktionelle-frage-WANN-antwort-WANN-lediglich,提出您的$  -  [F]
 

请注意,在规则本身的格局并不会导致与 / ,这是因为该规则,它的剥离,但对于%{REQUEST_URI} 变种,它是preserved。

Unbelievable, I could not find the solution to my newbie question. Maybe I used the wrong search terms? (htaccess block url, htaccess block single url, block specific url htaccess, ...)

I just have a page with this URL: http://www.gute-mathe-fragen.de/40224/redaktionelle-frage-wann-antwort-wann-lediglich-kommentar

I would like to block this URL because different bots (and humans) caused more than 4000 hits within one hour.

I tried the follwing within htaccess:

RewriteCond %{REQUEST_URI} ^40224\/$ [NC]
RewriteRule .* - [F]

without any success.

Which pro can help a beginner quickly? thx ;)

解决方案

When someone requests:

http://www.gute-mathe-fragen.de/40224/redaktionelle-frage-wann-antwort-wann-lediglich-kommentar

The %{REQUEST_URI} variable is:

/40224/redaktionelle-frage-wann-antwort-wann-lediglich-kommentar

And the regex ^40224\/$ will never match that. In fact, you don't even need a RewriteCond in this instance, just put the pattern in the rule:

RewriteRule ^40224/redaktionelle-frage-wann-antwort-wann-lediglich-kommentar$ - [F]

Note that the pattern in the rule itself doesn't lead with a /, it's because for the rule, it's stripped off, but for the %{REQUEST_URI} var, it's preserved.

这篇关于阻止通过htaccess的一个特定的URL。不能那么难的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 22:56