2013-10-24 69 views
0

我想我的域名從HTTP重定向到https:重定向到http://www.domain.com使用https://www.domain.com的.htaccess

http://www.domain.com --> https://www.domain.com 

這可能嗎?我一直在尋找周圍的互聯網,但我只發現:

http://domain.com --> https://www.domain.com 

的問題是,如何直接到達http://www.domain.com人民?他們不是使用非https網址嗎?反之亦然。我只想從HTTP到HTTPS的簡單重定向。可能嗎?

謝謝

回答

1

它將爲PHP的所有版本,並會迫使SSL和WWW所有裸域和鏈接:

RewriteCond %{HTTP_HOST} !^$ 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteCond %{HTTPS} off 
RewriteRule^https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE] 
  • 我們確實需要NE
  • WWW。在第4行是可選的
  • 「關」是必需的。
1

使用武力www和SSL使用下面的代碼:

RewriteCond %{HTTP_HOST} !^$ 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteCond %{HTTPS}s ^on(s)| 
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
2

I just want a simple redirection from the HTTP to HTTPS

嘗試在你的.htaccess這個簡單的規則作爲第一條規則:

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

你與Merianos尼科斯的魔術=結合。我想從非www重定向到www。然後,從www他們將重定向到https。這是完美的。謝謝你們倆!^_ ^ –

1

<IfModule mod_rewrite.c> 
 

 
RewriteEngine On 
 
RewriteCond %{HTTPS} off 
 

 
# Now, rewrite any request to the wrong domain to use www. 
 
RewriteCond %{HTTP_HOST} !^www\. 
 

 
RewriteCond %{HTTP_HOST} ^tatwerat\.com [NC] 
 

 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} 
 

 
</IfModule>