IIS重写规则,将特定域的URL重定向到同一域上的不同URL
问题描述:
我只希望IIS 7.5重写规则重定向 http://www.domain.com/url1到 http://www.domain.com/url2 (相同的域).这可以通过以下方式实现:
I simply want an IIS 7.5 rewrite rule to redirect http://www.domain.com/url1 to http://www.domain.com/url2 (same domain). This can be achieved by:
<rule name="Redirect url" enabled="true" stopProcessing="true">
<match url="^url1" />
<action type="Redirect" url="http://www.domain.com/url2"
appendQueryString="false" redirectType="Permanent" />
</rule>
但是,此网站侦听多个域,因此以上内容已成为所有域的全局规则.我该如何特定于domain.com?尝试更改匹配网址并添加条件,但无法使其正常工作.谢谢.
However, this website listens to several domains, thus above becomes a global rule for all domains. How do I make this specific to domain.com? Have tried changing match url and adding conditions but cannot get it to work. Thanks.
答
我可以这样工作:
<rule name="Redirect url1" stopProcessing="true">
<match url="^url1$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?domain.com$" />
</conditions>
<action type="Redirect" url="http://www.domain.com/url2"
appendQueryString="false" redirectType="Permanent" />
</rule>