2012-03-07 112 views
1

嗨,我想重定向我的域别名到一个域。web.config重定向多个域到一个

我现在有这个规则

<rule name="WWW Rewrite" enabled="true"> 
    <match url="(.*)" /> 
    <conditions> 
     <add input="{HTTP_HOST}" negate="true" 
     pattern="^www\.([.a-zA-Z0-9]+)$" /> 
    </conditions> 
    <action type="Redirect" url="http://www.domain.com/{R:0}" 
     appendQueryString="true" redirectType="Permanent" /> 
    </rule> 

它完美的作品时,别名可是没有前面的WWW ..我如何说重定向一切不等于这个领域

感谢

回答

2

试试吧。我不确定它是否有效,在这个主题中我不是很好,但是这里一直呆在这里4个月没有答案,所以我想我会给它一个wollop。

<rule name="Rewrite domain requests" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions> 
    <add input="{HTTP_HOST}" pattern="^(www.)?([.a-zA-Z0-9]+)$" /> 
    </conditions> 
    <action type="Rewrite" url="http://www.mydomain.com/url={R:1}" appendQueryString="true" /> 
</rule> 

这是我不确定的模式。我认为此说,在URL匹配任何东西,不论是否有WWW,和任何可能的领域扩展。

+0

我没有工作 – Zymotik 2012-10-04 12:58:48

1

为每个域添加一条规则。它使查询字符串太:

劳埃德张:http://forums.iis.net/t/1185885.aspx

<rule name="Domain Redirect" stopProcessing="true"> 
    <match url="(.*)" /> 
    <action type="Redirect" url="http://{C:1}mydomainalias.com/{R:1}" redirectType="Permanent" /> 
    <conditions> 
    <add input="{HTTP_HOST}" pattern="^(www\.)?mydomain\.com" /> 
    </conditions> 
</rule> 
0

这将解决您的问题。 您必须否定主域以避免重定向循环。

<rule name="Rewrite domain requests" stopProcessing="true" enabled="true"> 
    <match url="(.*)" /> 
    <conditions> 
    <add input="{HTTP_HOST}" pattern="^(www.)?([.a-zA-Z0-9]+)$" /> 
    <add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" /> 
    </conditions> 
    <action type="Redirect" url="http://www.domain.com/{R:1}" redirectType="Permanent" appendQueryString="true" /> 
</rule> 
相关问题