Welcome! Log In Create A New Profile

Advanced

Re: Rewrite URL with parameters

Jonathan Matthews
December 05, 2013 12:26PM
On 5 December 2013 17:09, Raphael R. O. <rabeloo@gmail.com> wrote:
> Hi guys,
>
> I'm trying to rewrite an url with a few parameters, but unsuccessfully.

You're almost there ;-)

> What i already tried:
>
> rewrite
> ^/category-body/categories/promotional(.*)utm_source=PromoCode&utm_medium=AddPromo&utm_campaign=PromoCode_AddPromo_moneycampainghttps://www.mysite.com.br/digital-parts/newspaper/recs-xyaw-sazz-qqad-cxae;

"rewrite" doesn't examine query strings, so if the contents of your
query string are required to drive your logic, you'll need to use
other tools instead of (or well as) rewrite.

> and ...
>
> location = /category-body/categories/promotional(.*)$ {

You probably don't want the "=" here. I don't actually know what a
regex ("(.*)") location used alongside "=" will do. I'm slightly
surprised nginx didn't complain on reload/restart ...

Have a read of this section: http://wiki.nginx.org/HttpCoreModule#location

You probably want to use a case-sensitive regex location.

> if ($args ~
> “utm_source=PromoCode&utm_medium=AddPromo&utm_campaign=PromoCode_AddPromo_moneycampaing”)

I'd use a map{} variable inside the if(), personally. The map can use
the same check as that which you have above, but in a way which
abstracts the actual check away from the logic that it drives. This is
just a stylistic change however :-)

HTH,
Jonathan

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewrite URL with parameters

Raphael R. O. December 05, 2013 12:10PM

Re: Rewrite URL with parameters

Jonathan Matthews December 05, 2013 12:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 172
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready