简体   繁体   English

如何阻止POST请求到以/ trackback / .htaccess结尾的网址?

[英]How can I block POST requests to urls ending with /trackback/ in .htaccess?

I'm wanting to block POST requests to a specific URL on a website. 我想阻止POST请求到网站上的特定URL。 Here is an example of a spammy POST request from my Apache log: 以下是来自我的Apache日志的垃圾邮件POST请求的示例:

110.86.178.xxx - - [14/Jan/2015:17:05:05 +0000] "POST /profile/example/trackback/ HTTP/1.1" 200 85 "http://example.com/profile/example/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) )"

I added the following code to the .htaccess file: 我将以下代码添加到.htaccess文件中:

# deny POST requests
<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_METHOD} POST
    RewriteRule /profile/example/trackback/ [F,L]
</IfModule>

Unfortunately I'm still receiving trackback emails, so it's not working. 不幸的是我仍然收到引用电子邮件,所以它不起作用。

What is the issue and how can I fix this? 问题是什么?我该如何解决这个问题? Also, how could I amend the code to block all POST requests sent to urls ending in /trackback/ 另外,我如何修改代码以阻止发送到以/ trackback /结尾的URL的所有POST请求

Thanks! 谢谢!

You can use this rule in root .htaccess: 您可以在root .htaccess中使用此规则:

RewriteEngine On

RewriteCond %{REQUEST_METHOD} POST
RewriteRule (^|/)trackback/?$ - [F,NC]

Try with: 试试:

# deny all POST requests
<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_METHOD} POST
    RewriteRule .* - [F,L]
</IfModule>

More info here . 更多信息在这里

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

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