2014-02-10 23 views
1

這裏HTTPS是一些代碼,我已經成功地挖掘:將流量重定向到www和使用的web.config重寫規則

<rule name="Redirect domain.com to www" patternSyntax="ECMAScript" stopProcessing="true"> 
<match url=".*" /> 
<conditions> 
<add input="{HTTP_HOST}" pattern="^inboxlock.com$" /> 
</conditions> 
<action type="Redirect" url="https://www.inboxlock.com/{R:0}" /> 
</rule> 

但是,如果有人類型www.inboxlock.com它不重定向到HTTPS。我需要www.inboxlock.com和domain.com重定向到https://www.inboxlock.com。請幫忙。謝謝。

回答

1
<rule name="Enforce WWW" stopProcessing="true"> 
    <match url=".*" /> 
    <conditions> 
    <add input="{CACHE_URL}" pattern="^(.+)://(?!www)(.*)" /> 
    </conditions> 
    <action type="Redirect" url="{C:1}://www.{C:2}" redirectType="Permanent" /> 
</rule> 

雖然我不能讚揚它。看到這個代碼和更多關於Mads Kristensen's blog post on URL rewrites

+0

關閉,但它仍然不存在。所有非www都重定向到www。但是,我需要所有www和非www的重定向到https:// www。一個不錯的文章雖然:) – DigitalRayne

+0

好吧,我設法使用你的代碼的組合來重定向到非www,我只是把一個https重定向在頁面加載,如在這裏看到的:http://stackoverflow.com/questions/47089/best-way-in-asp-net-to-force-https-for-an-entire-site。除非有人有更好的答案。謝謝 :) – DigitalRayne

相關問題