2012-03-07 68 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> 
相關問題