2016-02-02 33 views
5

ile başka bir etki alanına yönlendiriyor Bunun neden başarısız olduğuna dair hiçbir fikrim yok. Tüm etki alanını www.maindomain.com'a ve ayrıca httphttps'a yönlendirmek istiyorum, ne eksik? https:/www.maindomain.com/ içinApache2, ssl

# redirect http to https  
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

# redirect without www to www 
RewriteCond %{http_host} ^maindomain.com [nc] 
RewriteRule ^(.*)$ https://www.maindomain.com [r=301,nc] 

# redirect another domain to www.maindomain.com  
RewriteCond %{HTTPS} off # this i was missing 
RewriteCond %{HTTP_HOST} ^(www\.)?anotherdomain.com [NC] 
RewriteRule ^(.*)$ https://www.maindomain.com [R=301,L] 
  1. http://maindomain.comhttps:/www.maindomain.com/ için
  2. http://anotherdomain.comhttps:/www.maindomain.com/ için
  3. https://anotherdomain.com Kişisel Kural aşağıdaki satırı eksik olduğundan başka etki alanı için Https yönlendirme için HTTP başarısız
+0

garip, RewriteCond% {HTTPS} kapalı ipucundaki yorum şu an işe yarıyordu, ama yanıtı silmek istediğim gibi silindi, 3. yönlendirmede 2. RewriteCond eksik –

cevap

1

başarısız işleri :

RewriteCond %{HTTPS} off 

Dene:

# redirect another domain to www.maindomain.com  

RewriteCond %{HTTPS} off 

RewriteCond %{HTTP_HOST} ^(www\.)?anotherdomain.com [NC] 
RewriteRule ^(.*)$ https://www.maindomain.com [R=301,L] 
0

Bu deneyebilirsiniz:

RewriteEngine On 
RewriteCond %{HTTPS} !on 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

Sadece kopyalayıp .htaccess dosyasında Yukarıdaki kod sonra tüm web yönlendirilecek yapıştırmak, “https” ne zaman tarayıcı “http” modunda açılır. Tarayıcı, .htaccess'te yeniden yazarak yeniden yönlendirilir.