Skip to content

Instantly share code, notes, and snippets.

@mingsai
Created May 20, 2020 11:58
Show Gist options
  • Save mingsai/165197fe3d5b1378b1b11b4f44781b18 to your computer and use it in GitHub Desktop.
Save mingsai/165197fe3d5b1378b1b11b4f44781b18 to your computer and use it in GitHub Desktop.
Rewrite rules to hide folders (sub sites)
To hide the microsite directory in url, you can use the following rules:
<rewrite>
<rules>
<rule name="HideMicroSite" stopProcessing="true">
<match url="^microsite/(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^site\.com$" />
</conditions>
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="RewriteToMicroSite">
<match url="^(?!microsite)(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^site\.com$" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="microsite/{R:1}" />
</rule>
</rules>
</rewrite>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment