iamverylovely
V2EX  ›  Apache

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

  •  
  •   iamverylovely · Jul 26, 2019 · 4587 views
    This topic created in 2487 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   ·   862 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:46 · PVG 05:46 · LAX 14:46 · JFK 17:46
    ♥ Do have faith in what you're doing.