Skip to content

Instantly share code, notes, and snippets.

@FransdeJong
Created May 10, 2022 07:56
Show Gist options
  • Save FransdeJong/2a4e94d1cccd9bd931fbc128e592d1a3 to your computer and use it in GitHub Desktop.
Save FransdeJong/2a4e94d1cccd9bd931fbc128e592d1a3 to your computer and use it in GitHub Desktop.
Rewritemap for static rewrites
<rewriteMaps>
<rewriteMap name="nlRewrites">
<add key="/" value="https://www.newdomain.eu/nl"/>
<add key="/het-bedrijf" value="https://www.newdomain.eu/nl/over-ons/"/>
<add key="/producten/lamp value="https://www.newdomain.eu/nl/producten/verlichting/lamp"/>
</rewriteMap>
</rewriteMaps>
<rewrite>
<rules>
<rule name="Old nl urls">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(.*)?.domain.nl$" />
<add input="{nlRewrites:{PATH_INFO}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" redirectType="Permanent"/>
</rule>
<rules>
<rewrite>
@Digiover
Copy link

This works in my environment. Unfortunately this is without Umbraco, and I cannot reproduce your domain.nl / newdomain.eu structure, but that shouldn't matter. I redirect within one site.

`

  <rules>
    <rule name="Redirect rule for rewrite map">
      <match url=".*" />
      <conditions>
        <add input="{go:{PATH_INFO}}" pattern="(.+)" />
      </conditions>
      <action type="Redirect" url="{C:1}" appendQueryString="false" />
    </rule>
  </rules>

  <rewriteMaps>
    <rewriteMap name="go">
      <add key="/" value="https://example.com" />
      <add key="/test" value="servervars.aspx" />
    </rewriteMap>
  </rewriteMaps>

</rewrite>

`

Perhaps browser cache? I always use something like curl/wget on the commandline to test redirects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment