0
votes

I need a rewrite rule to redirect the root URL for a subfolder to the root of the domain, but I want to allow URLs in the subfolder. In other words:

  • www.domain.com/subfolder redirect to www.domain.com
  • www.domain.com/subfolder/ redirect to www.domain.com
  • www.domain.com/subfolder/page1 this should NOT redirect

Thanks!

1

1 Answers

0
votes

Try this:

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