iisurl-rewrite-module

How do I use IIS ReWrite redirect from server name to fully qualified domain name


I have an internal domain iis server which has a website that is bound to https

sitename and sitename.domain.com

but it also accepts http to

sitename and sitename.domain.com

I want to redirect using iis url rewrite so when someone enters http://sitename/?foo=bar it redirects to https://sitename.domain.com/?foo=bar

I also want to redirect url https://sitename/?foo=bar to https://sitename.domain.com/?foo=bar

I have not been able to get this working at all


Solution

  • You can try this rule:

    <rule name="test" stopProcessing="true">
      <match url="^(.*)$" />
        <conditions logicalGrouping="MatchAny">
          <add input="{HTTP_HOST}" pattern="^sitename$" />
          <add input="{HTTPS}" pattern="^OFF$" />
        </conditions>
      <action type="Redirect" url="https://sitename.domain.com/{R:1}" />
    </rule>