因为网站需要更换域名,但是之前的网站已经被搜索引擎收录了很多,且收录页面都是https的!
如果直接替换域名,之前搜索引擎收录的链接将无法打开。
所以必须将原先的https跳转到新域名的http上!
但我尝试修改了好几次config文件,都没有成功!
不知道如何修改才能实现https跳转到http?求教大神!
下面这个是网站的config文件:
server {
listen 80;
server_name www.xxx.com xxx.com;
rewrite ^/(.*) https://www.xxx.com/$1 permanent;
}
server {
listen 443;
server_name www.xxx.com;
ssl on;
ssl_certificate /usr/local/nginx/conf/cert/xxx.com.pem;
ssl_certificate_key /usr/local/nginx/conf/cert/xxx.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;
root /home/wwwroot/www.xxx.cn;
index index.html index.php index.htm;
error_page 400 /errpage/400.html;
error_page 403 /errpage/403.html;
error_page 404 /errpage/404.html;
error_page 405 /errpage/405.html;
include rewrite/diguo.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}
server
{
listen 80;
#listen [::]:80;
server_name www.xxx.com xxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/www.xxx.cn;
include rewrite/diguo.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}