nginx 301重定向
时间:2014-03-18 02:27 来源:linux.it.net.cn 作者:it
两种方式,在server段中进行判断,或直接另外针对要转向的域名写server段,最后用rewrite ^/(.*)$ http://目标网址/$1 permanent; 跳转。如:
server {
server_name www.wgjlb.com wgjlb.com ;
if ($host != 'www.w4s.cn' ) {
rewrite ^/(.*)$ http://www.wgjlb.com/$1 permanent;
}
...
}
server {
server_name w4s.cn;
rewrite ^/(.*) http://www.wgjlb.com/$1 permanent;
}
(责任编辑:IT)
两种方式,在server段中进行判断,或直接另外针对要转向的域名写server段,最后用rewrite ^/(.*)$ http://目标网址/$1 permanent; 跳转。如: server { server_name www.wgjlb.com wgjlb.com ; if ($host != 'www.w4s.cn' ) { rewrite ^/(.*)$ http://www.wgjlb.com/$1 permanent; } ... } server { server_name w4s.cn; rewrite ^/(.*) http://www.wgjlb.com/$1 permanent; }(责任编辑:IT) |