![](/img/trans.png)
[英]http not redirecting to https using Url Rewrite for whole URL in IIS 10 (URL containing parameters)
[英]Using IIS Url Rewrite from HTTPS to another HTTPS
我正在嘗試將我的網站從https://localhost
(但用ip編寫,例如https://10.0.7.8
)重定向到另一個https位置,例如https://mysite.com
我當前的配置是:
<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>
當我訪問https://10.0.7.8
它不會轉到https://mysite.com
,而是停留在https://10.0.7.8
知道我在做什么錯嗎?
您需要在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>
另外, 10.0.7.8
, 10.0.7.8
需要寫為10\\.0\\.7\\.8
.
需要轉義,因為它是一個特殊字符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.