【问题标题】:Simple rewrite from root domain to subdirectory IIS7从根域到子目录 IIS7 的简单重写
【发布时间】:2011-09-21 03:25:09
【问题描述】:

我知道如何重写的基础知识,但似乎无法找到一个符合我想要的方式的规则。

任何帮助将不胜感激:o)

    <rule name="RedirectRule" stopProcessing="true" enabled="true">
      <match url="^(.*)$" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^(www\.)?blah.com$" />
      </conditions>
      <action type="Rewrite" url="blog/{R:1}" />
    </rule>

基本上我希望它只重写:

  • www.blah.com --> www.blah.com/blog
  • blah.com --> www.blah.com/blog
  • www.blah.com/blog -->什么都不做。
  • www.blah.com/any-thing-else -->什么都不做。

【问题讨论】:

    标签: iis-7 url-rewriting


    【解决方案1】:

    添加第二个条件来检查 PATH_INFO 怎么样?看到您只想在未指定时重写...

    <add input="{PATH_INFO}" pattern="^$" negate="true" />
    

    检查 PATH_INFO 'Does Not Match the Pattern' ^$ 这是一个空字符串。

    我现在无法对此进行测试,因此可能需要调整...

    【讨论】:

      猜你喜欢
      • 2011-10-24
      • 2012-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 2011-05-10
      相关资源
      最近更新 更多