【问题标题】:Web.config rewrite root URL but not subfolderWeb.config 重写根 URL 但不重写子文件夹
【发布时间】:2015-09-10 12:40:23
【问题描述】:

我需要一个重写规则来将子文件夹的根 URL 重定向到域的根,但我想允许子文件夹中的 URL。换句话说:

  • www.domain.com/subfolder 重定向到 www.domain.com
  • www.domain.com/subfolder/ 重定向到 www.domain.com
  • www.domain.com/subfolder/page1 这不应该重定向

谢谢!

【问题讨论】:

    标签: url-rewriting web-config


    【解决方案1】:

    试试这个:

    <configuration>
      <location path="domain.com/subfolder">
        <system.webServer>
          <httpRedirect enabled="true" destination="http://domain.com" httpResponseStatus="Permanent" />
        </system.webServer>
      </location>
      <location path="domain.com/subfolder/">
        <system.webServer>
          <httpRedirect enabled="true" destination="http://domain.com" httpResponseStatus="Permanent" />
        </system.webServer>
      </location>
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多