V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
iamverylovely
V2EX  ›  Apache

LApache 虚拟主机设置.htaccess 实现全站 HTTPS

  •  
  •   iamverylovely · Jul 26, 2019 · 4563 views
    This topic created in 2479 days ago, the information mentioned may be changed or developed.

    Apache 虚拟主机实现 301 HTTPS WWW

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP:From-Https} !^on$ [NC,OR] 
    #如果某些页面没有 301,上一句改为:RewriteCond %{HTTPS} !^on$ [NC,OR]
    
    RewriteCond %{HTTP_HOST} ^iamverylovely.com$ [NC]
    RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R=301,L]
    </IfModule>
    

    结果是: http://iamverylovely.com http://www.iamverylovely.com https://iamverylovely.com

    全部跳转至: https://www.iamverylovely.com

    记录一下。

    备注:使用命令:curl -I 加上 URL,可以快速查看 Header。

    1 replies    2019-07-26 20:45:53 +08:00
    iamverylovely
        1
    iamverylovely  
    OP
       Jul 26, 2019
    标题多打了一个 L
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2961 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:50 · PVG 20:50 · LAX 05:50 · JFK 08:50
    ♥ Do have faith in what you're doing.