首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.NET Url重写根url

.NET Url重写根url
EN

Stack Overflow用户
提问于 2011-04-05 19:02:00
回答 2查看 8.7K关注 0票数 4

我在IIS7中有以下规则:

代码语言:javascript
复制
    <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>

它可以捕获urls,比如http://mysite.com/contact/

例如,我不知道如何使用规则来捕获http://mysite.com/并发送到home.aspx。有人能帮我解决匹配的正则表达式吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-04-05 21:45:29

我通过添加以下规则修复了它:

代码语言:javascript
复制
 <rule name="Index Request" enabled="true" stopProcessing="true">
     <match url="^$" />
     <action type="Rewrite" url="index.aspx" logRewrittenUrl="true" />
 </rule>
票数 16
EN

Stack Overflow用户

发布于 2011-04-05 19:05:38

为什么不在您的DNS服务器上设置一个规范名称(CName)来自动将http://domain.com重定向到http://www.domain.com

请参阅CName explanation on wikipedia

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5550777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档