1

Here's some code I've managed to dig up:

<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>

However, if someone types in www.inboxlock.com it doesn't redirect to https. I need both www.inboxlock.com and domain.com to redirect to https://www.inboxlock.com. Please help. Thanks.

DigitalRayne
  • 389
  • 2
  • 3
  • 14

1 Answers1

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>

I can't take credit for it though. See this code and more on Mads Kristensen's blog post on URL rewrites

rwisch45
  • 3,692
  • 2
  • 25
  • 36
  • Close but it's still not there. All non www's are redirected to www. But, I need all www's and non www's to redirect to https://www. A nice article though :) – DigitalRayne Feb 10 '14 at 04:42
  • Well, I've managed to use a combination of your code to redirect to from non www and I just put a https redirect in the page load as seen here: http://stackoverflow.com/questions/47089/best-way-in-asp-net-to-force-https-for-an-entire-site . Unless anyone has a better answer. Thanks :) – DigitalRayne Feb 10 '14 at 05:06