[英]Using IIS Url Rewrite from HTTPS to another HTTPS
I am trying to redirect my site from https://localhost
(but written with the ip, like https://10.0.7.8
) to another https location like https://mysite.com
我正在尝试将我的网站从
https://localhost
(但用ip编写,例如https://10.0.7.8
)重定向到另一个https位置,例如https://mysite.com
My current configuration is: 我当前的配置是:
<rewrite>
<rules>
<rule name="Rewrite to mysite.com" enabled="true" stopProcessing="true">
<match url="(.*)" />
<action type="Redirect" url="https://mysite.com/{R:0}" redirectType="Permanent" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="https://10.0.7.8*" />
</conditions>
</rule>
</rules>
</rewrite>
And when I am accessing https://10.0.7.8
it does not go to https://mysite.com
, it stays on https://10.0.7.8
当我访问
https://10.0.7.8
它不会转到https://mysite.com
,而是停留在https://10.0.7.8
Any idea what am I doing wrong? 知道我在做什么错吗?
You need to split the https
part from the ip in 2 conditions: 您需要在2种情况下将
https
部分与ip分开:
<rewrite>
<rules>
<rule name="Rewrite to mysite.com" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^10\.0\.7\.8$" />
<add input="{HTTPS}" pattern="^ON$" />
</conditions>
<action type="Redirect" url="https://mysite.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Also, 10.0.7.8
needs to be written 10\\.0\\.7\\.8
because the .
另外,
10.0.7.8
, 10.0.7.8
需要写为10\\.0\\.7\\.8
.
needs to be escaped as it is a special character. 需要转义,因为它是一个特殊字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.