问题描述
我将我的应用程序切换到https。我添加了system.webServer重写规则
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>
我的web.config中的
in my web.config
它将 http://mydomain.com
重写为 https://mydomain.com
哪个好。
Bot如何让它重写 http://www.mydomain.com
到 https://mydomain.com
(没有www)
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)
推荐答案
-
你可以制定单独的规则这会将www.mydomain.com更改为mydomain.com
You could make a separate rule that changes the www.mydomain.com into mydomain.com
你可以硬编码你的http_host而不是使用{HTTP_HOST}简单地放在那里:mydomain。 comso
You could just hardcode your http_host and instead of using {HTTP_HOST} simply put there: "mydomain.com" so
< action type =RedirectredirectType =Foundurl =https://mydomain.com/{R:1}/> ;
<action type="Redirect" redirectType="Found" url="https://mydomain.com/{R:1}" />
这篇关于IIS7将http和http:// www重写为https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!