Question about rewrite

Sasa Ugrenovic nginx-mailing at infomedia.ba
Sat Apr 5 14:44:48 MSD 2008


Ok.

Im off for the weekend, so I'll test it on monday.
Thank you.

Kind Regards,
Sasa

On Sat, 5 Apr 2008 05:57:55 -0400
"Denis S. Filimonov" <den.lists at gmail.com> wrote:

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





More information about the nginx mailing list