Having trouble understand how rewrite works

Denis F. Latypoff latypoff at yandex.ru
Wed Oct 19 16:27:33 UTC 2011


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.



More information about the nginx mailing list