其实很简单:
if ($server_port != '80' ) { rewrite ^/(.*)$ http://$host/$1 permanent; }
举一反三。。。
if ($server_port != '443' ) { rewrite ^/(.*)$ https://$host/$1 permanent; }
if ($host != 'host' ) { rewrite ^/(.*)$ http://host/$1 permanent; }
转载于:https://blog.51cto.com/314258/1897476