nginx配置,将根域名301重定向到带https的www域名下

将cgq0628.com、www.cgq0628.com、重定向到https://www.cgq0628.com,代码如下,将相关域名和ssl证书改为自己的就可以了

server {
    listen 80;
    server_name cgq0628.com www.cgq0628.com;
    return 301 https://www.cgq0628.com$request_uri;
}
server{
    listen 443;
    server_name cgq0628.com;
	ssl on;
    return 301 https://www.cgq0628.com$request_uri;
    ssl_certificate   /usr/local/nginx/conf/etc_cgq/1745751_www.cgq0628.com.pem;
    ssl_certificate_key  /usr/local/nginx/conf/etc_cgq/1745751_www.cgq0628.com.key;
}
server {
	listen 443;
	server_name www.cgq0628.com;
	ssl on;
	root /home/wwwroot/www.cgq0628.com;
	index index.html index.php;
	ssl_certificate   /usr/local/nginx/conf/etc_cgq/1745751_www.cgq0628.com.pem;
	ssl_certificate_key  /usr/local/nginx/conf/etc_cgq/1745751_www.cgq0628.com.key;
	......
		
}	

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.cgq0628.com/cms/24.html

说点什么吧

说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!