配置 www 和 https 跳转

AlexSJC
发布于 2024-08-07 / 21 阅读
2
0

配置 www 和 https 跳转

Nginx

server {
  listen 80;
  return 301 https://$host$request_uri;
}
server {
  listen 80;
  listen 443 ssl;
  server_name example.com;
  return 301 $scheme://www.example.com$request_uri;
}

Cloudflare

SSL/TLS > 边缘证书 > 始终使用 HTTPS

规则 > 重定向规则

规则名称:Redirect example.com to www.example.com

字段:主机名

运算符:等于

值:example.com

(http.host eq "example.com")

类型:动态

表达式:concat("https://www.example.com", http.request.uri.path)

状态代码:301

保留查询字符串


评论