且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

限制 POST 请求服务器

更新时间:2023-02-26 13:40:28

该块只会阻止来自 127.0.0.1 以外的主机的 POST 请求,并且您将收到 403 Forbidden 响应.您可以尝试使用 mod_rewrite 并将 替换为:

That block will only prevent POST requests from hosts other than 127.0.0.1, and you will get a 403 Forbidden response. You could try using mod_rewrite and replace the <LIMIT> with:

RewriteCond %{REQUEST_METHOD} POST

# allow the server to POST to itself
RewriteCond %{REMOTE_ADDR} !127.0.0.1   

# allow POST from trusted users
RewriteCond %{REMOTE_ADDR} !123.456.789.123   

# send all other post requests to 403 forbidden
RewriteRule ^ / [F]   

如果您希望将发布请求发送到您网站的主页,请将最后一行中的 [F] 替换为 [R,L]

If you would prefer to send post request to the home page of your site instead replace [F] in the last line with [R,L]

如果主页"不只是 /,您会将 / 替换为主页"所在的位置.

You'd replace the / with where your "home page" is if it isn't just /.