2011-04-05 72 views
2

我在IIS7後續規則:.NET URL重寫根URL

<rule name="RewriteAll" stopProcessing="true"> 
     <match url="^([^/]+)/?$" /> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
     <add input="{URL}" negate="true" pattern="\.axd$" /> 
     <add input="{URL}" negate="true" pattern="\.png$" /> 
     <add input="{URL}" negate="true" pattern="\.gif$" /> 
     <add input="{URL}" negate="true" pattern="\.jpg$" /> 
     <add input="{URL}" negate="true" pattern="\.css$" /> 
     <add input="{URL}" negate="true" pattern="\.js$" /> 
     </conditions> 
     <action type="Rewrite" url="default.aspx?page={R:1}" /> 
    </rule> 

該catch網址像http://mysite.com/contact/

我想不出用規則來使用捕捉http://mysite.com/併發送至例如home.aspx。誰能幫我用正則表達式匹配

回答

13

我通過添加下面的規則固定它:

<rule name="Index Request" enabled="true" stopProcessing="true"> 
    <match url="^$" /> 
    <action type="Rewrite" url="index.aspx" logRewrittenUrl="true" /> 
</rule> 
0

爲什麼不設置你的DNS服務器上的規範名稱(CNAME)自動重定向到http://domain.comhttp://www.domain.com

CName explanation on wikipedia

+0

離開負反饋,甚至沒有解釋的評論是相當差。 – 2011-04-06 08:07:22

+0

同意 - 沒有反饋的情況很差。這裏的類似建議也被低估了http://serverfault.com/a/88042 – Neil 2012-09-07 06:10:02