Nginx的301自动跳转规则怎么写?

Nginx中要实现:
http://www.pingdu.co/home/homepage-htm-uid-78655-m-newsview-id-197.html
自动跳转到
http://www.pingdu.co/hy/homepage-htm-uid-78655-m-newsview-id-197.html
,规则怎么写?
刚才根据您的规则设置了一个,好像没有成功。百度快照里有好多这样的链接啊:
http://www.pingdu.co/home/homepage-htm-uid-78655-m-newsview-id-197.html

http://www.pingdu.co/home/homepage-htm-uid-76013.html

http://www.pingdu.co/home/homepage-htm-uid-76922-m-newsview-id-143.html

http://www.pingdu.co/home/?m=info&uid=73862

http://www.pingdu.co/home/?m=contactus&uid=74213

http://www.pingdu.co/home/homepage-htm-uid-71965-m-newsview-id-14.html

http://www.pingdu.co/home/homepage-htm-uid-76069-m-newsview-id-102.html

http://www.pingdu.co/home/?m=info&uid=70932

http://www.pingdu.co/home/homepage-htm-m-job-uid-71281.html


真实的链接是把上述链接中的/home/换成/hy/就可以了,而又不能影响旺铺像下面这样的动态网址:
http://www.pingdu.co/home/?uid=80941

http://www.pingdu.co/home/?uid=76013

http://www.pingdu.co/home/?uid=80480
最新回答
七喜先生

2024-11-03 02:13:50

只跳转单个url:
rewrite ^/home/(homepage-htm-uid-78655-m-newsview-id-197.html) /hy/$1 permanent;
换成下面的试试:
if ($args ~ 'm=(info|contactus)') {
rewrite ^/home/ /hy/?m=$arg_m&uid=$arg_uid permanent;

}
rewrite ^/home/homepage(.*) /hy/homepage$1 permanent;