IIS URL Rewrite for redirect to FQDN

倖福魔咒の 提交于 2019-12-30 06:55:24

问题


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

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?


回答1:


This is the rule I would use:

<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>

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).



来源:https://stackoverflow.com/questions/18006963/iis-url-rewrite-for-redirect-to-fqdn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!