IIS URL 重写以重定向到 FQDN [英] IIS URL Rewrite for redirect to FQDN
问题描述
我正在尝试找出最佳 URL 重写规则来完成以下任务.
I am trying to figure out the best URL rewrite rule to accomplish the following.
http://intranet/sites/default.aspx rewrite to http://intranet.domain.com/sites/default.aspx
http://intranet rewrite to http://intranet.domain.com
同样在 IIS 中,该 Web 应用程序的 URL 绑定设置为intranet"
Also in IIS the URL binding is set to "intranet" for that web application
希望这是有道理的.有人可以帮忙改写规则吗?
Hope that makes sense. Can someone please help with the rewrite rule?
推荐答案
这是我会使用的规则:
<rule name="Intranet redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^intranet$" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="http://intranet.domain.com/{R:0}" />
</rule>
它将匹配完全命名为 http://intranet
(pattern="^intranet$"
并且 https
已关闭)并将其重定向到 http://intranet.domain.com/{R:0}
(其中{R:0}
是包含请求的任何路径的反向引用).
It will match any requested path (url="(.*)"
) on the host exactly named http://intranet
(pattern="^intranet$"
and with https
been turned off) and redirect it to http://intranet.domain.com/{R:0}
(where {R:0}
is a back reference containing whatever path was requested).
这篇关于IIS URL 重写以重定向到 FQDN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!