2015-09-09 24 views
7

IIS'nin WWW-WWW ve http - https'ye Yeniden Yönlendirmesi için iki kural uygulamaya çalışıyorum.IIS Yönlendirmesi www olmayan ve www ile http https

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

Yani, benim web.config bu ekledi:

<system.webServer> 
<rewrite xdt:Transform="Insert"> 
    <rules> 
    <rule name="Force WWW" enabled="true"> 
     <match url="(.*)" /> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^[^www]" /> 
     </conditions> 
     <action type="Redirect" url="https://www.zzz.com/{R:1}" appendQueryString="true" redirectType="Permanent" /> 
    </rule> 
    <rule name="Force HTTPS" enabled="true"> 
     <match url="(.*)" /> 
     <conditions> 
     <add input="{HTTPS}" pattern="off" /> 
     </conditions> 
     <action type="Redirect" url="https://www.zzz.com/{R:1}" appendQueryString="true" redirectType="Permanent" /> 
    </rule> 
    </rules> 
</rewrite>  

Sorum:

bir kuralda bu birleştirmek için bir yol var mı?

cevap

11

Evet, bunları bir araya getirebilir ve koşullar için logicalGrouping'i kullanabilir ve "VEYA" değerine eşdeğer olan birime ayarlayabilirsiniz. Örneğin:

<rule name="Force WWW and SSL" enabled="true" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions logicalGrouping="MatchAny"> 
     <add input="{HTTP_HOST}" pattern="^[^www]" /> 
     <add input="{HTTPS}" pattern="off" /> 
    </conditions> 
    <action type="Redirect" url="https://www.zzz.com/{R:1}" appendQueryString="true" redirectType="Permanent" /> 
</rule> 
+0

Çalışıyor. Teşekkür ederim! –

+0

Merhaba, kendi sorunum için bunu deneyin 2012 https://example.com/ o zaman hatalara gitmeye çalıştığımda IIS 8 kazanın. http://example.com https://www.example.com ve example.com'a gider ancak https://example.com beni sadece bu siteye götürür Bu siteye ulaşılamıyor example.com'un sunucu DNS adresi bulunamadı. Dene: bağlantıyı vekil, güvenlik duvarı ve DNS yapılandırmasını ERR_NAME_NOT_RESOLVED – MonkeyMagix

+0

Denetleme Denetleme sayfa Reloading Ben Sen 4 bağlamaları gerekiyor www – MonkeyMagix

İlgili konular