Skip to content

Instantly share code, notes, and snippets.

@prabirshrestha
Created August 5, 2011 23:03
Show Gist options
  • Save prabirshrestha/1128735 to your computer and use it in GitHub Desktop.
Save prabirshrestha/1128735 to your computer and use it in GitHub Desktop.
Staging Applications using url rewrite
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- Stage A:
A(enabled) B(enabled,negate)
Stage B:
A(enabled,negate) B(enabled)
Production A:
A(enabled,negate) B(enabled)
Production B:
A(enabled) B(enabled,negate)
Live A:
A(enabled,comment) B(disabled)
Live B:
A(disabled) B(enabled,comment) -->
<remove name="Use A" />
<remove name="Use B" />
<rule name="Use A" stopProcessing="true">
<conditions>
<!--<add input="{Authorized Admin IPs:{REMOTE_ADDR}}" pattern="1" negate="true"/>-->
</conditions>
<match url="^(.*)$" ignoreCase="true" />
<action type="Rewrite" url="a/{R:1}" />
</rule>
<rule name="Use B" stopProcessing="true" enabled="false" >
<conditions>
<add input="{Authorized Admin IPs:{REMOTE_ADDR}}" pattern="1" />
</conditions>
<match url="^(.*)$" ignoreCase="true" />
<action type="Rewrite" url="b/{R:1}" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="Authorized Admin IPs">
<add key="110.34.4.242" value="1" />
</rewriteMap>
</rewriteMaps>
</rewrite>
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment