Having trouble understand how rewrite works
victor
noagbodjivictor at gmail.com
Wed Oct 19 17:08:03 UTC 2011
Ah sorry, this one was meant for you Denis, not sure how gmail handled it.
---
Thanks again. I understand the map solution. Here's another issue, you
see, the links below all map to the index page (there are other pages
too, that have those PageID, ParentPageID, etc.. parameters).
/index.cfm?PageID=1
/index.cfm?resetCache=yes
/index.cfm?PageID=1&ParentPageID=1&NavID=1
/index.cfm?PageID=22&ParentPageID=1&NavID=22
/index.cfm?PageID=14&ParentPageID=38&NavID=38&ReferringPage=1
all map to / (index)
/index.cfm?PageID=35&ParentPageID=26&NavID=26
/index.cfm?PageID=35&ParentPageID=26&NavID=35&ProductID=8&PageText=off
/index.cfm?PageID=35&ParentPageID=26&NavID=35&ProductID=9&PageText=off
/index.cfm?PageID=35&ParentPageID=26&NavID=35&ProductID=10&PageText=off
/index.cfm?PageID=35&ParentPageID=26&NavID=35&ProductID=15&PageText=off
/index.cfm?PageID=35&ParentPageID=26&NavID=35&ProductID=16&PageText=off
/index.cfm?PageID=35&ParentPageID=26&NavID=35&ProductID=11&PageText=off
and these for example would map to another unique page.
The parameters specify the actual page that must be mapped to. And
since I now know I can't use regex on query parameters, is there a way
to handle this situation?
2011/10/19 Denis F. Latypoff <latypoff at yandex.ru>:
> 19.10.2011, 23:32, "victor" <noagbodjivictor at 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 at yandex.ru>:
>>
>>> 19.10.2011, 22:53, "victor" <noagbodjivictor at 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 at nginx.org
>>>> http://mailman.nginx.org/mailman/listinfo/nginx
>>> --
>>> br, Denis F. Latypoff.
>>>
>>> _______________________________________________
>>> nginx mailing list
>>> nginx at nginx.org
>>> http://mailman.nginx.org/mailman/listinfo/nginx
>> --
>> Victor Noagbodji
>> http://www.victorsreviews.com
>>
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>
> --
> br, Denis F. Latypoff.
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
--
Victor Noagbodji
http://www.victorsreviews.com
More information about the nginx
mailing list