Reputation: 10358
I switched my application to https. I added system.webServer rewrite rule
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
in my web.config
It rewrites http://mydomain.com
to https://mydomain.com
which is good.
Bot how to make it to rewrite also http://www.mydomain.com
to https://mydomain.com
(without www)
Upvotes: 1
Views: 1124
Reputation: 1674
You could make a separate rule that changes the www.mydomain.com into mydomain.com
You could just hardcode your http_host and instead of using {HTTP_HOST} simply put there: "mydomain.com" so
<action type="Redirect" redirectType="Found" url="https://mydomain.com/{R:1}" />
Upvotes: 1