2013-01-31 130 views

回答

0

里面你location块,当你管理这个链接(第一个),你可以使用指令set可变$args如下:

set $args $args&download; 

可变$args代表查询字符串当前执行。再长一点例如:

location /public.php { 
    set $args $args&download; 

    # rest of your code here 
} 

其他方式做到这一点是在这里:

location ~ ^/public.php?service=([^&]+)&t=([^&]+)$ { 
    set $args ""; # it's needed for nginx to it doesn't append two times query string 
    rewrite .* $uri?$query_string&download; 
} 

location ~ ^/public.php?(.*)&download$ { 
    # do your job here 
} 

回写它的工作对你的问题。

+0

如何获取当前的public.php参数作为变量? – r2r

+0

它在nginx变量'$ query_string'或'$ args'中可用,但是第一个是只读的 – emka86