asp.net - 重定向主页

标签 asp.net regex iis iis-7 url-rewriting

我想要的是将 poo.example.com 重定向到 poo.example.com/home.ashx 但我失败了以下代码;

<rewrite>
  <rules>
    <rule name="Redirect to HTTPS" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
    </rule>
    <rule name="Redirect poo.example.com to poo.example.com/home.ashx" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="(./)" />
      <action type="Redirect" url="https://{HTTP_HOST}/home.ashx" />
    </rule>
  </rules>
</rewrite>

我使用的是 IIS 7.5。

注意

我厌倦了使用默认文档,但它不起作用。我的应用程序是一个 ASP.NET MVC 应用程序。它可能与此有关,但这不是这里的问题。我需要使用 IIS URL 重写功能来实现这一点。

最佳答案

您只需将 home.ashx 添加为 IIS 中的默认文档(确保它出现在列表顶部),然后就不需要进行任何 URL 重写。

关于asp.net - 重定向主页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6762866/

相关文章:

c# - 如何阻止 asp.net 阻止对文件的访问然后在构建时抛出拒绝访问错误?

c# - div 位置内的图像按钮

MySQL:如果值仅为数字则更新列

java - 接受最多 5 位数字和小数的正则表达式

c# - ASP.NET Identity 有时无法登录

ASP.NET MVC 自定义授权

c# - 如何修复 InvalidOperationException : The model item passed into the ViewDataDictionary is of type

c++ - C/C++ PCRE 是否可以匹配 UTF-8 字符串中相距很远的 2 个或更多 UTF-8 代码点?

c# - 临时 block REST Controller

c# - 在 VS10 中调试时未命中断点