• 微讯云企服平台,创业路上与你相伴!
  • 打开微信扫一扫,
    您还可以在这里找到我们哟

    关注我们

  • 帮助中心

    Apache自动跳转到 HTTPS

    网站根目录新建 .htaccess 

    RewriteEngine On 

    RewriteCond %{SERVER_PORT} 80 

    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]


    RewriteEngine On 

    RewriteCond %{SERVER_PORT} 80 

    RewriteCond %{HTTP_HOST} ^example.com [NC,OR] 

    RewriteCond %{HTTP_HOST} ^www.example.com [NC] 

    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]


    高级用法 (可选)

    RewriteEngine on 

    # 强制HTTPS 

    RewriteCond %{HTTPS} !=on [OR] 

    RewriteCond %{SERVER_PORT} 80 

    # 某些页面强制 

    RewriteCond %{REQUEST_URI} ^something_secure [OR] 

    RewriteCond %{REQUEST_URI} ^something_else_secure 

    RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] 

    # 强制HTTP 

    RewriteCond %{HTTPS} =on [OR] 

    RewriteCond %{SERVER_PORT} 443 

    # 某些页面强制 

    RewriteCond %{REQUEST_URI} ^something_public [OR] 

    RewriteCond %{REQUEST_URI} ^something_else_public 

    RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]