2016-07-24 58 views
0

我用下面的代碼在我的.htaccess的.htaccess上轉發HTTP到HTTPS加強迫WWW

RewriteCond %{HTTPS} off 
RewriteRule !^(index(\.php)?)?$ https://%{HTTP_HOST}/$1 [R=301,L] 

這項工作做得很好了HTTPS當我添加

RewriteCond %{HTTP_HOST} !^www\. 
RewriteCond %{HTTPS} off 
RewriteRule !^(index(\.php)?)?$ https://www.%{HTTP_HOST}/$1 [R=301,L] 

迫使WWW盈它只能強制www infront但不轉發http到https。

在此

回答

0

任何幫助要執行www和在同一規則htpp->https使用OR 2之間的條件:

RewriteCond %{HTTP_HOST} !^www\. [NC,OR] 
RewriteCond %{HTTPS} on 
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] 
RewriteCond %{THE_REQUEST} /index\.php [NC] 
RewriteRule^http://www.%1%{REQUEST_URI} [R=301,L,NE] 

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

第三RewriteCond是用於捕獲域的值之後www.

+0

其forwading指數到https,我希望索引是http – meandme

+0

好吧現在嘗試我更新的答案。 – anubhava

+0

它的工作www.website.com/index.php,但由於主頁是index.php轉發到httpswww.website.com。而不是httpwww.website.com – meandme

相關問題