中國站
幫助中心 > 安全 > SSL安全證書 > 證書安裝 > Apache自動跳轉到 HTTPS

Apache自動跳轉到 HTTPS

網站根目錄新建 .htaccess

  1. RewriteEngine On
  2. RewriteCond %{SERVER_PORT} 80
  3. RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
  4. RewriteEngine On
  5. RewriteCond %{SERVER_PORT} 80
  6. RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
  7. RewriteCond %{HTTP_HOST} ^www.example.com [NC]
  8. RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

高級用法 (可選)

  1. RewriteEngine on

強制HTTPS

  1. RewriteCond %{HTTPS} !=on [OR]
  2. RewriteCond %{SERVER_PORT} 80

某些頁面強制

  1. RewriteCond %{REQUEST_URI} ^something_secure [OR]
  2. RewriteCond %{REQUEST_URI} ^something_else_secure
  3. RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

強制HTTP

  1. RewriteCond %{HTTPS} =on [OR]
  2. RewriteCond %{SERVER_PORT} 443

某些頁面強制

  1. RewriteCond %{REQUEST_URI} ^something_public [OR]
  2. RewriteCond %{REQUEST_URI} ^something_else_public
  3. RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女