qiufengluoye
V2EX  ›  问与答

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

  •  
  •   qiufengluoye · May 3, 2024 · 1495 views
    This topic created in 756 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
        1
    itechify  
    PRO
       May 4, 2024 via Android
    nginx 配置跳转,有手就行
    JasonQii
        2
    JasonQii  
       May 4, 2024
    JasonQii
        3
    JasonQii  
       May 4, 2024
    然后 配置文件里面加 return 301 https://xxx.xx.xxx;
    isAK47
        4
    isAK47  
       May 4, 2024
    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   ·   Solana   ·   2933 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 08:49 · PVG 16:49 · LAX 01:49 · JFK 04:49
    ♥ Do have faith in what you're doing.