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;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章