Skip to content

Instantly share code, notes, and snippets.

@SpiritLing
Last active April 26, 2022 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpiritLing/c0f12694158378594991a3084c433df3 to your computer and use it in GitHub Desktop.
Save SpiritLing/c0f12694158378594991a3084c433df3 to your computer and use it in GitHub Desktop.
2020-01-14-iis-url-rewrite
<?xml version="1.0" encoding="UTF-8"?>
<!--- Origin Release:https://blog.spiritling.cn/posts/82f57ccc/ -->
<!--- Origin Develop:https://dev.blog.spiritling.pub/posts/82f57ccc/ -->
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<!-- htpt => https -->
<rule name="demo-https" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{HTTP_HOST}" pattern="^demo\.example\.com$" />
</conditions>
<action type="Redirect" url="https://demo.example.com/{R:1}" />
</rule>
<!-- https domain/4436 => https domain:4436 -->
<rule name="demo" enabled="true" stopProcessing="true">
<match url="^4436/(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^ON$" />
<add input="{HTTP_HOST}" pattern="^demo\.example\.com$" />
</conditions>
<action type="Rewrite" url="https://demo.example.com:4436/{R:1}" />
</rule>
<!-- domain => https://localhost -->
<rule name="index" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^test\.example\.com$" />
</conditions>
<action type="Rewrite" url="https://localhost" />
</rule>
</rules>
</rewrite>
<caching enabled="false" enableKernelCache="false" />
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment