nginx rewrite

nginx rewrite

1.www跳转不带www

if ( $host != 'xx.com' ){
    rewrite ^/(.*)$ http://xx.com/$1 permanent;
}

2.指定页面跳转http,其他页面跳转https

vim xx.conf
if ( $request_uri !~ 'abc.html|def.html' ){
    rewrite ^/(.*)$ https://xx.com/$1 permanent;
 }

vim xx_https.conf
if ( $request_uri ~ 'abc.html|def.html' ){
    rewrite ^/(.*)$ http://xx.com/$1 permanent;
 }

猜你喜欢

转载自my.oschina.net/2726276586/blog/1806551