Welcome! Log In Create A New Profile

Advanced

Re: Having trouble understand how rewrite works

Denis F. Latypoff
October 19, 2011 12:38PM
19.10.2011, 23:32, "victor" <noagbodjivictor@gmail.com>:
> Hi Dennis,
>
> Thanks for your help,
>
> If I understand correctly, I need to use $arg_PARAMS. But in the full
> source, I have expressions like this one:
>
> /index\.cfm\?PageID=(2|46)&(.*)$

map $arg_PageID $is_old {
default 0;
2 1;
46 1;
}

server {
location = /index.cfm {
if ($is_old) {
return 301 /;
}
# regular rules
}
}

>
> how do I deal with them in that case, if I can't use regex on the
> query parameters?
>
> Thanks
>
> 2011/10/19 Denis F. Latypoff <latypoff@yandex.ru>:
>
>>  19.10.2011, 22:53, "victor" <noagbodjivictor@gmail.com>:
>>>  Here's a small sample that is not working:
>>>
>>>  server {
>>>          # /index.cfm?PageID=1  --> /
>>  -         location ^~ /index\.cfm\?PageID=1$ {
>>  -                 rewrite ^ / permanent;
>>  +         location = /index.cfm {
>>  +                 if ($arg_PageID = 1) {
>>  +                         return 301 /;
>>  +                 }
>>  +                 try_files $uri @django;
>>>          }
>>>
>>>          location / {
>>>                  try_files $uri @django;
>>>          }
>>>
>>>          location @django {
>>>                  proxy_redirect      off;
>>>                  proxy_set_header    Host            $host;
>>>                  proxy_set_header    X-Real-IP       $remote_addr;
>>>                  proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
>>>
>>>                  include uwsgi_params;
>>  +                 # 'if' is useless here
>>  -                 if (!-f $request_filename) {
>>>                      uwsgi_pass staging;
>>  -                     break;
>>  -                 }
>>>          }
>>>  }
>>>
>>>  It seems like the first directive is ignored when I request
>>>  /index.cfm?PageID=1. The idea is to redirect some old links.
>>>
>>>  Thanks
>>>
>>>  --
>>>  Victor Noagbodji
>>>  http://www.victorsreviews.com
>>>
>>>  _______________________________________________
>>>  nginx mailing list
>>>  nginx@nginx.org
>>>  http://mailman.nginx.org/mailman/listinfo/nginx
>>  --
>>  br, Denis F. Latypoff.
>>
>>  _______________________________________________
>>  nginx mailing list
>>  nginx@nginx.org
>>  http://mailman.nginx.org/mailman/listinfo/nginx
> --
> Victor Noagbodji
> http://www.victorsreviews.com
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

--
br, Denis F. Latypoff.

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

Having trouble understand how rewrite works

victor October 19, 2011 11:54AM

Re: Having trouble understand how rewrite works

Denis F. Latypoff October 19, 2011 12:28PM

Re: Having trouble understand how rewrite works

victor October 19, 2011 12:34PM

Re: Having trouble understand how rewrite works

Denis F. Latypoff October 19, 2011 12:38PM

Re: Having trouble understand how rewrite works

victor October 19, 2011 01:10PM

Re: Having trouble understand how rewrite works

locojohn October 19, 2011 12:39PM

Re: Having trouble understand how rewrite works

locojohn October 19, 2011 12:40PM

Re: Having trouble understand how rewrite works

victor October 19, 2011 12:52PM

Re: Having trouble understand how rewrite works

António P. P. Almeida October 19, 2011 08:22PM

Re: Having trouble understand how rewrite works

victor October 19, 2011 12:52PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 148
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready