2012-10-25 52 views

回答

1

使用RewriteRule以匹配什麼存在超越/,如果匹配,重寫爲SSL:

RewriteEngine On 
# If ssl is not already active 
RewriteCond %{HTTPS} !=on 
# .+ matches one or more of any character... An empty string would not match 
RewriteRule ^(.+)$ https://%{HTTP_HOST]}%{REQUEST_URI} [L,R=301] 
0

通過httpd.conf啓用mod_rewrite的和的.htaccess,然後把這個代碼在你.htaccessDOCUMENT_ROOT目錄:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteCond %{HTTPS} !=on 
RewriteRule ^.+$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

RewriteCond %{HTTPS} =on 
RewriteRule ^$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]