IIS URL Rewrite: Match subdomain and redirect to HTTPS

iisredirectionrewrite

Suppose the website URL is subdomain.company.com

I want to redirect the user to https://subdomain.company.com only if

  1. The original request is not using https
  2. subdomain matches subdomain.comapny.com

Relative URL and query string should append as expected.

I cannot edit web.config. So I have to do this via IIS only.

In IIS, I have tried the following but it is not giving desired results-

enter image description here

enter image description here

How could this be achieved?

Best Answer

Your "Match URL" pattern is where you want to define subdomain.company.com. Your "Conditions" pattern should be off, because you want to redirect when {HTTPS} is off. Also, if this is a permanent redirect, you may as well change the "Action" to Permanent (301).