Url rewriting Web.config重写根URL但不重写子文件夹

Url rewriting Web.config重写根URL但不重写子文件夹,url-rewriting,web-config,Url Rewriting,Web Config,我需要一个重写规则将子文件夹的根URL重定向到域的根,但我希望允许子文件夹中的URL。换言之: www.domain.com/subfolder重定向到www.domain.com www.domain.com/subfolder/重定向到www.domain.com www.domain.com/subfolder/page1此操作不应重定向 谢谢 试试这个: <configuration> <location path="domain.com/subfolder"&

我需要一个重写规则将子文件夹的根URL重定向到域的根,但我希望允许子文件夹中的URL。换言之:

  • www.domain.com/subfolder重定向到www.domain.com
  • www.domain.com/subfolder/重定向到www.domain.com
  • www.domain.com/subfolder/page1此操作不应重定向
谢谢

试试这个:

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