目的:将所有wangqiao123.com abc.wangqiao123.com 域名自动跳转到www.wangqiao123.com


server {

                 listen             80;

                 server_name    wangqiao123.com abc.wangqiao123.com;

                 charset    utf-8;

                 index index.html index.htm index.php;

                 root /usr/local/nginx/htdocs;

                 if ($http_host !~ “^www\.wangqiao123\.com$”){

                                rewrite ^(.*) http://www.wangqiao123.com$1 redirect;

                 }

                 ………

}