<p dir="ltr">On 28 Jul 2013 10:08, "edogawaconan" <<a href="mailto:me@myconan.net">me@myconan.net</a>> wrote:<br>
><br>
> On Sun, Jul 28, 2013 at 11:55 AM, ron ramos <<a href="mailto:nhadie@gmail.com">nhadie@gmail.com</a>> wrote:<br>
> > Hi All,<br>
> ><br>
> > Been trying to block bots from accessing a URI that has a query_string<br>
> > "action=get_it", i tried below<br>
> ><br>
> ><br>
> >         location ~* \?(action=get_it)$ {<br>
> ><br>
> >                 if ( $http_user_agent ~<br>
> > (crawl|Googlebot|Slurp|spider|bingbot|tracker|click|parser|spider)) {<br>
> ><br>
> >                         return 404;<br>
> ><br>
> >                         break;<br>
> ><br>
> >                 }<br>
> ><br>
> >          }<br>
> ><br>
> > i just learned that location does not match query string, if i do the is_arg<br>
> > i cant do nested if, anyone able to do this before?<br>
> ><br>
> > TIA.<br>
> ><br>
><br>
> I don't remember the exact syntax but something like this should work:<br>
><br>
> if ($arg_action = get_it) { set $no_bot 1; }<br>
> if ($http_user_agent ~ <keys>) { set $is_bot 1; }<br>
> if ($no_bot$is_bot = 11) { return 404; }</p>
<p dir="ltr">I would personally use a map{} which examined both variables and then a single if() to take action based on the map's result. </p>
<p dir="ltr">I'd be interested in any official comment from nginx staff about the relative merits of these approaches ...</p>
<p dir="ltr">J</p>