# Should we use "if ( $request\_method." or "limit\_except."?

**URL:** <https://www.ruby-forum.com/t/should-we-use-if-request-method-or-limit-except/223299>\
**Category:** NGINX\
**Created:** [September 28, 2012, 1:05pm UTC](https://www.ruby-forum.com/t/should-we-use-if-request-method-or-limit-except/223299 "2012-09-28T13:05:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [September 28, 2012, 1:05pm UTC](https://www.ruby-forum.com/t/should-we-use-if-request-method-or-limit-except/223299/1 "2012-09-28T13:05:12Z")

</div>

Hello list,

Can anybody tell me if the bellow constructs are equivalent?

server {  
…  
if ( $request\_method !~ ^(?:GET|HEAD|POST)$ ) { return 444; }  
…

server {  
…  
location / {  
limit\_except GET HEAD POST { deny all; }  
…

And, if they are equivalent, in the case of having multiple locations,  
is it still better to have a limit\_except for each location? Or, in  
this case is it better to have a single “if ( $request\_method …” at  
server level ?

Thank you,  
Mark
