LNMP https 301不带www 跳转 www 问题
军哥:我一个网站 http 跳转 https 没问题 。
现在问题是 https 不带www的没办法跳转到带www的如果http2再加一个301就提示重复重定向 如果是要在ssl的虚拟主机直接设置301肯定是重复重定向
ssl虚拟主机里 不带www的跳转到带www的一般是这样
if ($host = 'vpser.net') {
return 301 https://www.vpser.net$request_uri;
}
多谢军哥指导 已经解决!
多谢军哥指导 已经解决!因为主网站申请ssl次数过多 要等一周再申请才行,下面贴出这个问题的 ssl配置
域名是 ssjcfj.cn测试站
server
{
listen 80;
#listen [::]:80;
server_name www.ssjcfj.cn ssjcfj.cn;
return 301 https://www.ssjcfj.cn$request_uri;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/www.ssjcfj.cn;
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 off;
}
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name www.ssjcfj.cn ssjcfj.cn;
if ($host = 'ssjcfj.cn') {
return 301 https://www.ssjcfj.cn$request_uri;
}
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/www.ssjcfj.cn;
ssl on;
ssl_certificate /usr/local/nginx/conf/ssl/www.ssjcfj.cn/fullchain.cer;
ssl_certificate_key /usr/local/nginx/conf/ssl/www.ssjcfj.cn/www.ssjcfj.cn.key;
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 other.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-pathinfo.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.ssjcfj.cn.log;
}
回复 3# 的帖子
太感谢了 只有这样弄才可以谢谢
页:
[1]