我有一个旧网址www.mydomain.com/customer/1。我将该服务器更改为ww2,它在ww2.mydomain.com/customer/1上显示正常。在我的新IIS 8.5 www服务器上,我如何输入重写规则,因此如果用户访问www.mydomain.com/customer/1,他们将重定向到ww2.mydomain.com/customer/1。我在Url Rewrite 2.0模块中尝试过很多模式,似乎没什么用。所有其他www请求我不想重定向,那些留在我的新www服务器上。
答案 0 :(得分:0)
我想重定向单个路径/customer/1
,然后您应该将其添加到Web.config
服务器上的www.mydomain.com
:
<rewrite>
<rules>
<rule name="Redirect 'www.mydomain.com/customer/1' to 'ww2.mydomain.com/customer/1'" stopProcessing="true">
<match url="^customer/1$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.mydomain\.com$" />
</conditions>
<action type="Redirect" url="http://ww2.mydomain.com{REQUEST_URI}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
如果您希望包含其他路径,可以使用<match url="^customer/1$" />
标记中指定的RegEx。