IIS Rewrite mapping
Author
Discussion

TheAngryDog

Original Poster:

13,276 posts

240 months

Monday 10th February 2020
quotequote all

I am trying to use the remapping functionality in IIS and have it reference a .config file. I am doing this because our website gets updated regularly, and when it does a new web.config is created as it has new information. This plays havoc with my existing rewrite rules and I have to replace them each time.

I came across rewrite mapping and found a guide, but this doesn't seem to work.

https://ruslany.net/2010/05/storing-url-rewrite-ma...

My current rules do the following;

1) redirect any http traffic to https

2) redirect you to a folder if you just type in the host name

3) return a response if the server is queried for what it is powered by

XML
<rules>
<rule name="HTTP to HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://website.domain.com/{R:1}" />
</rule>
<rule name="Redirect to sub folder" enabled="true" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/foldername" />
</rule>
</rules>
<outboundRules>
<rule name="Response Server" enabled="true">
<match serverVariable="RESPONSE_SERVER" pattern=".*" />
<action type="Rewrite" value="More Dreams" />
</rule>
</outboundRules>

When I follow that guide it doesn't actually do any redirecting.

Has anyone used remap rules before? Can you offer any assistance please?

I know I could the rules hard coded, but we build this website several times for different urls (it's a SaaS website).

Thanks.