http无法成功跳转到https,加301代码网页就变成重定向
现在网站无法跳转到对应的https,如:http://www.snsnz.com/shehua/ 跳转不了https://www.snsnz.com/shehua/我加下面这行代码变成重定向,打不开网页,代码如下
return 301 https://www.snsnz.com$request_uri;
不加就无法跳转,详情代码在下面,有知道的人麻烦告诉一下,谢谢(根目录无.htaccess文件)
server
{
listen 80;
#listen [::]:80;
server_name www.snsnz.com snsnz.com;
return 301 https://www.snsnz.com$request_uri;
if ($host != 'www.snsnz.com' )
{
rewrite ^/(.*)$ https://www.snsnz.com/$1 permanent;
}
if( $http_user_agent ~* "(iPhone|iPad|iPod|iOS|Android|Mobile|nokia|samsung|htc|blackberry)")
{
rewrite ^/tag/(.*)$ https://m.snsnz.com/tag/$1 permanent;
}
index index.html index.php;
root/home/wwwroot/www.snsnz.com;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
location ~* ^/m/
{
rewrite ^/m/(.*)$ https://m.snsnz.com/$1 permanent;
}
include proxy-pass-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/home/wwwlogs/www.snsnz.com.log;
}
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name www.snsnz.com;
index index.html index.php;
root/home/wwwroot/www.snsnz.com;
ssl on;
ssl_certificate /etc/letsencrypt/live/www.snsnz.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.snsnz.com/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
# openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include proxy-pass-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 443 ssl http2;
#listen [::]:443 ssl http2;
server_name snsnz.com;
return 301 https://www.snsnz.com$request_uri;
ssl on;
ssl_certificate /etc/letsencrypt/live/www.snsnz.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.snsnz.com/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
# openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include proxy-pass-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;
}
按你目前贴出的配置文件看是没有问题的,只是你虚拟主机一开始就加了个301跳转,下面的各种if判断都是没用的了
打不开返回什么错误信息?
licess 发表于 2021-5-20 08:16
按你目前贴出的配置文件看是没有问题的,只是你虚拟主机一开始就加了个301跳转,下面的各种if判断都是没用 ...
谢谢军哥耐心回复,如果加了代码则返回下面图示,如果去掉则可以打开网站,但就是不能从http跳到https,这个怎么弄?
第三个 server{ } 无限 301 重定向到 https
第三个 server 配置是不是有些多余?
补充内容 (2021-5-25 09:49):
看走眼了,配置没问题 hutaoseven 发表于 2021-5-25 08:41
第三个 server{ } 无限 301 重定向到 https
第三个 server 配置是不是有些多余?
现在加301重定向,网页就打不开,真的郁闷 caiheqing 发表于 2021-6-6 13:46
现在加301重定向,网页就打不开,真的郁闷
nginx上仅按你目前贴出的配置文件是没啥问题的
如果使用了cdn之类的那就很可能是你cdn上的问题
实在搞不定可以联系qq/旺旺付费排查 licess 发表于 2021-6-6 19:59
nginx上仅按你目前贴出的配置文件是没啥问题的
如果使用了cdn之类的那就很可能是你cdn上的问题
谢谢军哥,我解决了 caiheqing 发表于 2021-6-8 15:57
谢谢军哥,我解决了
怎么解决的
什么问题,解决过程贴一下啊,省得别人重复的找轮子 很酷很拽的昵称 发表于 2021-6-13 19:34
怎么解决的
什么问题,解决过程贴一下啊,省得别人重复的找轮子
花钱让别人搞定了
页:
[1]