2011-04-05 76 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