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 particular 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();