2013-08-02 129 views
2

我想找出最好的URL重写规则来完成以下操作。IIS URL重写重定向到FQDN

http://intranet/sites/default.aspx rewrite to http://intranet.domain.com/sites/default.aspx 

http://intranet rewrite to http://intranet.domain.com 

而且在IIS中的URL绑定被设置为“内联网”为Web应用程序

希望是有道理的。有人可以帮助重写规则吗?

+0

你到目前为止尝试过些什么吗? – cheesemacfly

+0

是的,没有任何东西可以工作,我必须承认我之前没有做过很多重写。我过去做的唯一的URL重写是请求uri重定向。 –

+0

所以规则应该重写任何请求的路径或只有'sites/default.aspx'? – cheesemacfly

回答

5

这是规则,我会用:

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

它将完全匹配命名​​(pattern="^intranet$"https被关闭)的主机上的任何请求的路径(url="(.*)"),并将其重定向到http://intranet.domain.com/{R:0}(其中{R:0}是包含所请求的任何路径的后向引用)。

+0

这工作!我在模式结尾错过了$,可能导致我想的重定向循环。谢谢你的时间。 –