gpt4 book ai didi

ssl - Nginx 让加密无法重定向到 www

转载 作者:太空宇宙 更新时间:2023-11-03 14:34:52 24 4
gpt4 key购买 nike

我的网站在 www 和非 www 两种 https 访问中均有效。我还将重定向从非 www 更改为 www,并且它有效。所有访问都重定向到 https://www.example.com

但是,目前我的网站无法重定向到 www,即使使用相同的 nginx 默认配置。这里是

server {
add_header X-Frame-Options SAMEORIGIN;
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com www.example.com;
return 301 https://server_name$request_uri;}

server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
client_max_body_size 500M;

root /var/www/html/src/public;

index index.php index.html index.htm index.nginx-debian.html;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}

location ~ \.php$ {
add_header X-Frame-Options SAMEORIGIN;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_nam$
include fastcgi_params;
}

location ~ /.well-known {
allow all;
}

location ~ /\.ht {
deny all;
}

我正在使用 VPS debian 8.9 x64,nginx/1.6.2

最佳答案

您可以尝试如下更新您的 http 服务器 block 吗?

server {
server_name example.com www.example.com;
return 301 https://www.example.com$request_uri;
}

请引用https://stackoverflow.com/a/48811022/2196316对于 nginx session ...

关于ssl - Nginx 让加密无法重定向到 www,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48877689/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com