代码之家  ›  专栏  ›  技术社区  ›  Chris Muench

如何为*强制使用https。example.com?

  •  0
  • Chris Muench  · 技术社区  · 14 年前

    如何为*强制使用https。example.com?

    我试过:

    RewriteCond %{HTTPS} !=on
    RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
    
    2 回复  |  直到 14 年前
        1
  •  0
  •   GôTô    14 年前
        2
  •  0
  •   Stephen Holiday    14 年前

    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
    

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^(sub1|sub2|sub3)\. [NC]
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]