本文介绍了如何阻止IP地址的POST请求,但没有得到什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,我收到了很多垃圾评论。综观IP地址的垃圾邮件来源,他们大多是从它不太可能有任何真正的人会想用我的英文网站互动的国家,因此它是有道理的,我简单地阻止他们。

I have a website where I'm getting quite a lot of comment spam. Looking at the IP addresses the spam originates from, they're mostly from countries where it's unlikely any real humans would want to interact with my English-language website, so it makes sense for me to simply block them.

这应该是相当简单的,但是我想,如果这些国家的交通居然可以查看我的内容,只是没有进入评论,注册等形式。因此,有效地我想让他们做GET方法,而不是POST方法的。

This should be quite straightforward, however I'd like it if traffic from these countries could actually view my content, just not access the comment, registration etc. forms. So effectively I want to allow them to make GET method requests, but not POST method ones.

在理想情况下,我想做到这一点,在.htaccess文件的网站,而不是实际的编码成动力的网站上的PHP脚本。经过一番搜索,我发现了我认为正是我需要的。看来,我可以做完全如上:

Ideally, I'd like to do this in the .htaccess file for the site rather than actually coding it into the PHP scripts that power the site. After a bit of searching, I found what I thought was exactly what I needed: . It appeared that I could do exactly as described above with:

# Block China, Russia etc. from POSTs and similar methods
<Limit POST PUT DELETE>
order deny,allow
deny from 210.5.214.128/29
deny from 210.89.69.160/28
# Hundreds more lines...
# My current IP (sample provided here, actual used in reality), to test
deny from 100.100.100.100
allow from all
</Limit>

# Allow anyone to do GETs and HEADs
<Limit GET HEAD>
order deny,allow
allow from all
</Limit>

但它没有达到预期效果。我所能做的GET请求(如需要),但帖还仍然工作正常,我或许会想到一个403 Forbidden错误。

But it's not having the desired effect. I can do GET requests (as desired), but POSTs also still work as normal where I would expect a 403 Forbidden error perhaps.

如果我不使用标签,并把我的IP的拒绝列表,它确实成功地prevent我访问的网站(GET和POST)。

If I don't use the tag and put my IP in the deny list, it does successfully prevent me from accessing the site (both GET and POST).

谁能告诉我是什么,我需要改变吗?

Can anyone advise me as to what I need to change?

推荐答案

更​​改允许否认这样的顺序:

Change the order of allow deny like this:

<Limit POST PUT DELETE>
order allow,deny
allow from all
deny from 210.5.214.128/29
deny from 210.89.69.160/28
# Hundreds more lines...
# My current IP (sample provided here, actual used in reality), to test
deny from 100.100.100.100
</Limit>

<Limit GET HEAD>
order deny,allow
allow from all
</Limit>

这篇关于如何阻止IP地址的POST请求,但没有得到什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:06
查看更多