Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
watch
V2EX  ›  Linux

nginx 301 配置问题

  •  
  •   watch · Jan 9, 2020 · 2970 views
    This topic created in 2340 days ago, the information mentioned may be changed or developed.
    域名:a.com

    需求:将 a.comwww.a.com ( http 及 https 协议)全部重定向到 https://www.a.com

    这样写配置可以吗:

    server {
    listen 80;
    listen 443 ssl http2;
    server_name www.a.com a.com;
    if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
    if ($host != www.a.com) { return 301 $scheme://www.a.com$request_uri; }
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2714 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 15:33 · PVG 23:33 · LAX 08:33 · JFK 11:33
    ♥ Do have faith in what you're doing.