Restrict POST Request The Server

后端 未结 1 2000
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 13:44

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

相关标签:
1条回答
  • 2021-02-04 14:14

    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]   
    

    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 /.

    0 讨论(0)
提交回复
热议问题