2016-09-30 201 views

回答

0

在.htaccess

RewriteCond %{SERVER_PORT} ^80$ 
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] 
0

您可以使用這些重定向規則在站點根目錄的.htaccess:

RewriteEngine On 

# for abcd.com 
RewriteCond %{HTTP_HOST} !^www\. [NC,OR] 
RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_HOST} ^(?:www\.)?(abcd\.com)$ [NC] 
RewriteRule^https://www.%1%{REQUEST_URI} [R=301,L,NE] 

# for rest 
RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE] 
+0

@ user2818066:這篇作品出來? – anubhava

0

試試這個,

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^www 
RewriteRule https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301] 

RewriteCond %{HTTPS} off 
RewriteRule https://%{HTTP_HOST}%{REQUEST_URI} [R=301]