【问题标题】:.NET Url rewrite the root url.NET Url 重写根 url
【发布时间】:2011-07-29 21:02:51
【问题描述】:

我在 IIS7 中有以下规则:

    <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>

捕获像http://mysite.com/contact/这样的网址

我不知道用什么规则来捕获http://mysite.com/ 并发送到例如 home.aspx。谁能帮我匹配正则表达式

【问题讨论】:

    标签: iis-7 url-rewriting


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

      CName explanation on wikipedia

      【讨论】:

      • 在没有解释评论的情况下留下负面反馈是非常糟糕的。
      • 同意没有反馈的 -ves 很差。这里的类似建议也被否决了serverfault.com/a/88042
      猜你喜欢
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-25
      • 1970-01-01
      • 2013-07-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多