http://abcd.com ,http://www.abcd.com ,https://abcd.com 自动跳转https://www.abcd.com nginx配置

server {
	 listen 80;
	 server_name www.abcd.com  abcd.com;   
	 rewrite ^(.*)$ https://$host$1 permanent;
	 location / {
		index index.html index.htm;
		}
}

server {
        listen       443 ssl;
        server_name  www.abcd.com  abcd.com;
        #ssl on;
        ssl_certificate      /usr/local/nginx/conf/3749980_www.abcd.com_nginx/3749980_www.abcd.com.pem;
        ssl_certificate_key  /usr/local/nginx/conf/3749980_www.abcd.com_nginx/3749980_www.abcd.com.key;
        ssl_session_timeout  5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers   on;
		
		if ($http_host !~ '^www\.abcd\.com$') {
			rewrite ^(.*) https://www.abcd.com$1 redirect;
		} 

        root /home/www/wwwroot/abcd/public;
        index index.html index.htm index.php;
        include enable-php.conf;

        location / {
                #try_files $uri $uri/ /index.php?$query_string;
				try_files $uri $uri/ /index.php$is_args$query_string;
        }
	access_log /home/www/wwwlogs/abcd.log;
}

 


版权声明:本文为lvshuocool原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。