我在我的网站上看到通常大量的 HTTP POST 请求,我想知道:是否有任何方法可以通过修改 php 文件或 .htaccess 文件来阻止特定 php 页面上的 POST 请求?提前致谢!
最佳答案
在 native PHP 中,它就像检查一个 $_SERVER
一样简单变量:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
die('Post is not allowed');
}
在.htaccess
内, 使用 <Files>
的组合和 <limit>
:
<Files myfile.php>
<Limit POST>
Order deny,allow
Deny from all
</Limit>
</files>
关于php - 阻止 HTTP POST 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5009326/