2012-12-05 30 views
6

在我們的web.config文件中,我們控制了6個不同的國際域。IIS 7多域名主頁Canonical Redirect

我們如何做到與1個規則如下:

重定向

  • www.1of6Domains.com/index.htm
  • www.1of6Domains.com/index.html
  • WWW .1of6Domains.com/Default.asp的
  • www.1of6Domains.com/default.aspx

  • www.1of6Domains.com

像這樣的事情?

<rule name="Canonical Redirect" enabled="true" stopProcessing="true"> 
    <match url="(.*)/(index.html|index.htm|default.asp|default.aspx)" /> 
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> 
    <action type="Redirect" url="{R:1}" /> 
</rule> 

回答

2

我會去:

<rule name="Canonical Redirect" enabled="true" stopProcessing="true"> 
    <match url="^index.html$|^index.htm$|^default.asp$|^default.aspx$" /> 
    <action type="Redirect" url="/" /> 
</rule> 

如果說www.1of6Domains.com你的意思是每個域可能是不同的,那麼動作一定要(要記住它假定非HTTPS流量): <action type="Redirect" url="http://www.1of6Domains.com" />

編輯: 下面是處理多個域的規則(它可能有一個規則,但是重寫地圖將需要創建的,不知道你希望這樣的併發症):

<rule name="Canonical Redirect Non Https"> 
    <match url="^index.html$|^index.htm$|^default.asp$|^default.aspx$" /> 
    <action type="Rewrite" url="http://{HTTP_HOST}/" /> 
    <conditions> 
     <add input="{HTTPS}" pattern="^OFF$" /> 
    </conditions> 
</rule> 

<rule name="Canonical Redirect Https"> 
    <match url="^index.html$|^index.htm$|^default.asp$|^default.aspx$" /> 
    <action type="Rewrite" url="https://{HTTP_HOST}/" /> 
    <conditions> 
     <add input="{HTTPS}" pattern="^ON$" /> 
    </conditions> 
</rule> 
+0

會有使用相同的規則,所以這將需要努力同它們全部6個不同的領域。 – Brent