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)
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}" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.