
输入(2次):
192.168.1.252/abtest/lp1.html?cid=1&c3=2&c6=a
分别页面跳转到:
http://192.168.1.252/ab/a/lp1.html?cid=1&c3=2&c6=a ----》echo a
http://192.168.1.252/ab/b/lp1.html?cid=1&c3=2&c6=a----- 》echo b
配置:
虚拟主机配置文件中加入(监听a页面的server段里):
这里单纯是修改参数的部分。 $1是前面(.*)的值,如 域名 / 后输入的xxx.html。
$query_string 内置变量是url参数。
~* 正则匹配
$arg_参数名 接收源url参数的值 。
最后的? 号 表示不会再转发传递过来原地址的问号?后面的参数那部分,最后如果不加? 就会在更改完参数后,再次连上一段源地址的参数。
如:输入192.168.1.252/abtest/lp1.html?cid=1&c3=2&c6=a
按照以上配置应该跳转到 http://192.168.1.252/ab/a/lp1.html?cid=2&c3=2&c6=a
$arg_参数名最后不加? 就会显示 http://192.168.1.252/ab/a/lp1.html?cid=2&c3=2&c6=a&cid=1&c3=2&c6=a
整体配置:
确保安装 nginx 时 ./configure 有加入 --with-http_perl_module 这一项,然后在 nginx.conf 配置文件的http{}内、server{}前面加入:(加入内容在结构上与 server{} 并列)perl_set $urldecode 'sub {my $inf = shiftmy $url = $inf-argsmy $inx = index($url, "redirect=",)my $redirect = ""if ($inx <0) {$redirect = $url}else {my $red = substr($url, $inx+9,)my $len = index($red, "\x26",)if ($len <0) {$redirect = substr($red, 0,)}else{$redirect = substr($red, 0, $len)}}$redirect =~ s/\%([A-Fa-f0-9]{2})/pack("C", hex($1))/segreturn $redirect}'在 server 的 location 内加入:(加入内容在 location 之内,location 在 server 之内)if ($arg_redirect) {最后,重新启动 nginxPS: 以上的$urldecode是变量名,可以更改把文件放在nginx的html文件夹中(前提是你的nginx/conf/nginx.conf中配置server的root就是html),比如nginx/html/abc.bin然后访问localhost/abc.bin就可以i直接下载欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)