0

I need url-rewrite (or any other method) do the following:

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

I've seen a lot of posts to redirect to www and a lot to force https but none of them that does both.

Thanks

fxxxit
  • 23
  • 7

2 Answers2

0

this should help:

<rule name="Redirect to www" stopProcessing="true">
  <match url="(.*)" />
  <conditions trackAllCaptures="true">
    <add input="{CACHE_URL}" pattern="^(.+)://" />
    <add input="{HTTP_HOST}" pattern="^domain\.com$" />
  </conditions>
  <action type="Redirect" url="{C:1}://www.domain.com/{R:1}" />
</rule>
Tom Hall
  • 4,258
  • 2
  • 23
  • 23
  • Thanks for that. I actually found another answer on SO as well (http://stackoverflow.com/a/17715586/2412080). Still need to implement so will try both of these. – fxxxit Feb 02 '15 at 05:02
0

this rule i use is applying WWW for both http and https (just copy and paste) :

<rule name="ensure 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>

hope this helps.

Chtioui Malek
  • 11,197
  • 1
  • 72
  • 69