限制POST请求的服务器

编程入门 行业动态 更新时间:2024-10-28 12:27:09
本文介绍了限制POST请求的服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要限制通过 .htacces 来自其他服务器的所有POST请求 如果他们试图张贴任何来自其他服务器的事情,他们会重定向到主页或404等。 我想这

I want to restrict all POST request that comes from other server via .htacces if they try to post any from other server thing they will get redirected to home page or 404 etc. I tried this

<Limit POST> order deny,allow deny from all allow from 127.0.0.1 </Limit>

注: - GET请求,允许来自所有服务器。只有阻止POST请求。

Note:- GET request are allowed from all servers. Only to block POST requests.

推荐答案

这是块只会prevent员额从主机127.0.0.1以外的请求,你会得到一个403禁止响应。你可以尝试使用mod_rewrite和替换&LT;极限&GT; 与

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]

如果您需要preFER到post请求发送到您的网站的主页上,而不是替换 [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 /.

更多推荐

限制POST请求的服务器

本文发布于:2023-10-09 16:37:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476218.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:服务器   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!