qiufengluoye
V2EX  ›  问与答

ksweb 搭建的网站如何在配置文件里将 http 强制跳转至 https 啊?

  •  
  •   qiufengluoye · May 3, 2024 · 1947 views
    This topic created in 920 days ago, the information mentioned may be changed or developed.

    ksweb 搭建的网站如何在配置文件里将 http 强制跳转至 https 啊? 服务器为 nginx 。 一名小白,在网络上试了很多办法都不行。

    4 replies  •  2024-05-04 14:29:03 +08:00
    itechify
    itechify
    May 4, 2024 via Android
    1
    nginx 配置跳转,有手就行
    JasonQii
    JasonQii
    May 4, 2024
    2
    JasonQii
    JasonQii
    May 4, 2024
    3
    然后 配置文件里面加 return 301 https://xxx.xx.xxx;
    isAK47
    isAK47
    May 4, 2024
    4
    server {
    ......
    ......
    ......
    if ($host ~ '^baidu.com'){
    return 301 https://www.baidu.com$request_uri;
    }
    if ($server_port !~ 443){
    rewrite ^(/.*)$ https://$host$1 permanent;
    }
    ......
    ......
    ......
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1011 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 18:38 · PVG 02:38 · LAX 10:38 · JFK 13:38
    ♥ Do have faith in what you're doing.