请教军哥,https如何跳转到http
请教军哥,之前用的lnmp配置的免费SSL证书,但是最近不知道怎么都过期了,索性就改回http,但是搜索引擎记录的都还是https页面,有没有办法自动跳转到http呢?从论坛看到http 301到https的方法,反向操作没成功。 把http到https 的301设置反过来就行了https 主机上设置301,http 是正常的虚拟主机就行了
回复 2# 的帖子
试了几次还是不行,请军哥看下下面的配置,server{
listen 80;
#listen [::]:80;
server_name www.xxx.net xxx.net;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/www.xxx.net;
include none.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/home/wwwlogs/www.xxx.net.log;
return 301 http://www.xxx.net$request_uri;
}
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name www.xxx.net ;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/www.xxx.net;
if ($host = 'xxx.net') {
return 301 http://www.xxx.net$request_uri;
}
ssl on;
ssl_certificate /etc/letsencrypt/live/www.xxx.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.xxx.net/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;
include none.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/home/wwwlogs/www.xxx.net.log;
}
回复 3# 的帖子
你这配置能成功才怪http虚拟主机你加啥301,删掉
https虚拟主机里你加啥if,判断啥host,判断删掉只留301代码,另外server_name都没写全,none www的域名呢
回复 4# 的帖子
感谢军哥百忙之中还能回复,修改后貌似还是不行,代码如下:server{
listen 80;
#listen [::]:80;
server_name www.xxx.net xxx.net;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/www.xxx.net;
include none.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/home/wwwlogs/www.xxx.net.log;
}
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name www.xxx.net xxx.net;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/www.xxx.net;
return 301 http://www.xxx.net$request_uri;
ssl on;
ssl_certificate /etc/letsencrypt/live/www.xxx.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.xxx.net/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
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;
include none.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/home/wwwlogs/www.xxx.net.log;
}
回复 5# 的帖子
可能没重启或reload nginx,没有的话配置文件肯定不会生效 做个猜想,会不会跟HSTS有关?比如之前设置过这个,时间又比较长,据说一旦进了这个目录,后头一直会以SSL加密方式走。不过楼主为何不再继续申请和续SSL证书呢?一键包下,这个挺方便的,何况你引擎上收录的还已经是HTTPS了。
回复 5# 的帖子
另外301也是有缓存的
页:
[1]