IIS URL rewrite

Michael Beaver 0 Reputation points
2023-04-05T15:09:27.5966667+00:00

I'm wanting to setup 2 rules for my site in IIS:

  1. HTTP to HTTPS
  2. non-WWW to WWW

I have #1 working for my site, but can't get #2 to work.
I created rule 1 based upon: https://aboutssl.org/iis-redirection-http-to-https/ I tried to create rule 2 based upon: https://weblogs.asp.net/owscott/iis-url-rewrite-rewriting-non-www-to-www When I add rule 2 to the site in IIS, the site processes rule 1 pointing to HTTPS and ignores rule 2 the secure non www version.

Windows for business Windows Server User experience Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2023-04-05T16:04:32.24+00:00

    Change the bindings in your main site to only support HTTPS. (Remove HTTP.) Add rule #2 to that site. Remove rule #1.

    Add a second web site, Set the bindings to only use HTTP with the host name of your main site. In the HTTP Redirect section, set it to redirect all requests to the HTTPS://www.whatever.com main site.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.