<div>Hi.</div>
<div>So "last" means "finish this time and repeat matching from the start", and "break" means "finish rewrite"?</div>
<div>But I confused which situation we need "break", if I just finish rewrite rule--- I maybe don't need rewrite.<br>In my case, I need to redirect a "internal" location, so I must use "last" here?</div>
<div>( /openpath/file.ext ====> @realpath/cache_file.ext )</div>
<div> </div>
<div> location ~^ /openpath/ {</div>
<div> rewrite /openpath/(\w+)\.(\w+) @realpath/cache_$1.$2 last;</div>
<div> }</div>
<div> </div>
<div> location ~^ @realpath/ {</div>
<div> alias /realpath;</div>
<div> internal;</div>
<div> }</div>
<div> </div>
<div><span class="gmail_quote">2008/4/5, Denis S. Filimonov <<a href="mailto:den.lists@gmail.com">den.lists@gmail.com</a>>:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">The last directive tells nginx to finish url rewriting and do the location<br>matching again with the updated url. However, I just realized that you are<br>
redirecting to another host, so probably what you need is "redirect"<br>or "permanent." That will just redirect the user with 302 or 301 code.<br>Sorry for the confusion.<br><br>On Saturday 05 April 2008 05:43:38 Sasa Ugrenovic wrote:<br>
> Ok, thanks. That was helpful.<br>><br>> However, Im don't fully understand the last directive.<br>><br>> # last - completes processing of rewrite directives, after which searches<br>> for corresponding URI and location<br>
><br>> How will it effect if i have multiple rewrite rules ?<br>> To be exact.. i have a file, mobile-phones.conf which is included in vhost<br>> nginx config, for my primary domain. And it looks something like this:<br>
><br>> # if ($http_user_agent !~* "Profile/MIDP") {<br>> # rewrite ^/ <a href="http://www.anotherhost.com/">http://www.anotherhost.com/</a>;<br>> # }<br>><br>> # if ($http_user_agent !~* Windows\ CE) {<br>
> # rewrite ^/ <a href="http://www.anotherhost.com/">http://www.anotherhost.com/</a>;<br>> # }<br>><br>> So on.. around 10 rewrite rules.<br>><br>> Basicly... question is, do I use 'last' directive on all of those rewrite<br>
> rules, or just the last one in mobile-phones.conf list ?<br>><br>> Kind Regards,<br>> Sasa<br>><br>> On Sat, 5 Apr 2008 04:50:56 -0400<br>><br>> "Denis S. Filimonov" <<a href="mailto:den.lists@gmail.com">den.lists@gmail.com</a>> wrote:<br>
> > On Saturday 05 April 2008 04:40:26 Sasa Ugrenovic wrote:<br>> > > Hey,<br>> > ><br>> > > Be aware that the orginal User Agent line looks something like this:<br>> > > "SonyEricssonW800i/R1BC Browser/SEMC-Browser/4.2 Profile/MIDP-2.0<br>
> > > Configuration/CLDC-1.1"<br>> > ><br>> > > Do<br>> > ><br>> > > > if ($http_user_agent !~* "Profile/MIDP") {<br>> > ><br>> > > this still stands ? I mean, Will it match the *profile/midp* ?<br>
> ><br>> > Yes, .*profile/midp.* to be exact. The quotes are probably optional in<br>> > this case, the essential part was the "last" keyword in rewrite.<br>> ><br>> > > Kind Regards,<br>
> > > Sasa<br>> > ><br>> > > On Sat, 5 Apr 2008 04:25:19 -0400<br>> > ><br>> > > "Denis S. Filimonov" <<a href="mailto:den.lists@gmail.com">den.lists@gmail.com</a>> wrote:<br>
> > > > On Saturday 05 April 2008 04:00:10 Sasa Ugrenovic wrote:<br>> > > > > Hello,<br>> > > > ><br>> > > > > I moved one site from apache to nginx, and I must say... Im very<br>
> > > > > satisfied. Wont get into details about that now, just to say -<br>> > > > > thanks on the cool project.<br>> > > > ><br>> > > > > Anyway, to get to the point.<br>
> > > > > Im running mostly mobile site, so.. I don't wanna pc desktop users<br>> > > > > browsing around, instead.. I want to redirect those users to<br>> > > > > another site.<br>
> > > > ><br>> > > > > I did a little reasearch about that, and... the only option of how<br>> > > > > I can match those users is the "Profile/MIDP" part of UserAgent<br>
> > > > > string. 99 % of wap browsers send that, and other 1% sends<br>> > > > > variations on that, like opera: J2ME/MIDP. So I think thats the<br>> > > > > best deal.<br>> > > > ><br>
> > > > > I created rules like this:<br>> > > > ><br>> > > > > if ($http_user_agent !~* Profile/MIDP) {<br>> > > > > rewrite ^/ <a href="http://www.anothersite.com/">http://www.anothersite.com/</a>;<br>
> > > > > }<br>> > > > ><br>> > > > > However, that aint working right. So obviously im doing something<br>> > > > > wrong. Can someone help me how I can properly match that string ?<br>
> > > ><br>> > > > if ($http_user_agent !~* "Profile/MIDP") {<br>> > > > rewrite ^/ <a href="http://www.anothersite.com/">http://www.anothersite.com/</a> last;<br>
> > > > }<br>> > > ><br>> > > > <a href="http://wiki.codemongers.com/NginxHttpRewriteModule#rewrite">http://wiki.codemongers.com/NginxHttpRewriteModule#rewrite</a><br>> > > ><br>
> > > > --<br>> > > > Denis.<br>> ><br>> > --<br>> > Denis.<br><br><br><br>--<br>Denis.<br><br></blockquote></div><br><br clear="all"><br>-- <br>bianbian coding life:<br><a href="http://bianbian.org">http://bianbian.org</a>