需求:
地址
http://testa/inlinePreview/live.html?id=463738305721405440
重定向到
http://testb/shares/live.html?newsId=463738305721405440 break;
nginx配置:
在testa的nginx中配置
if ($request_uri = /inlinePreview/live.html?id=463738305721405440){
rewrite ^ http://testb/shares/live.html?newsId=463738305721405440 break;
}
请求http://testa/inlinePreview/live.html?id=463738305721405440在nginx中$request_uri为去掉http://testa的部分
即/inlinePreview/live.html?id=463738305721405440
nginx配置if and方法:
set $a 0;
if ($request_uri ~ id=376332472792911872$){ #以id=376332472792911872结尾
set $a 1;
}
if ($request_uri ~ ^/inlinePreview){ #以/inlinePreview开头
set $a 1$a;
}
if ($a = 11 ){
rewrite ^ http://news.bandaoapp.com/shares/live.html?newsId=376332472792911872 break;
}