开发者

Block HTTP POST request

I am seeing an usually high number of HTTP POST requests on my website, and I was wondering: Is there any way to block a POST request on a particul开发者_JAVA百科ar php page by making modifications to either the php file or .htaccess file? Thanks in advance!


In native PHP it's as simple as checking one $_SERVER variable:

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    die('Post is not allowed');
}

Within .htaccess, use a combination of <Files> and <limit>:

<Files myfile.php>
    <Limit POST> 
        Order deny,allow 
        Deny from all 
    </Limit>
</files>


if ($_SERVER['REQUEST_METHOD']) == 'POST') die();


POST /test HTTP/1.1 Host: foo.example Content-Type: application/x-www-form-urlencoded Content-Length: 27

field1=value1&field2=value2

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜