小编tho*_*tho的帖子

nginx 将 http 重定向到 https 不起作用

我正在尝试从 http 重新路由到 https。例如,您访问 example.com,您将被自动重定向到https://example.com

我尝试使用这个:

server {
      listen         80;
      return 301 https://$host$request_uri;
} 
Run Code Online (Sandbox Code Playgroud)

还有这个:

server {
      listen         80;
      server_name    example.com;
      return         301 https://$server_name$request_uri;
}
Run Code Online (Sandbox Code Playgroud)

如此处所示:在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https?

但似乎两者都不适合我。我留在example.com。

有人有想法吗?

linux http nginx https redirect

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

http ×1

https ×1

linux ×1

nginx ×1

redirect ×1