Search code examples
iisurl-rewritingdomain-name

Rewrite domain to specific language content without changing url - IIS


I have multiple domain names pointed to the same server (example.nl)

The example.my url should point to the content of example.nl/en, without having this url to appear in the adress bar. This is only really necessary for the homepage (due to google addwords issues).

To summarize, example.my should show the content of example.nl/en while showing example.my in the adress bar.

The current rule is giving me an error. Any tips?

<rule name="Redirect .my" stopProcessing="true">
   <match url=".*" />
   <conditions>
      <add input="{HTTP_HOST}" pattern="^.*example\.my$" />
   </conditions>
   <action type="Rewrite" url="http://www.example.nl/en/" />
</rule>

Solution

  • This seems to do the trick for me:

    <rule name="redirect .my to /en" enabled="true" stopProcessing="true">
      <match url="(^$)" ignoreCase="true" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="example.my" />
      </conditions>
      <action type="Redirect" url="http://www.example.my/en/{R:1}" appendQueryString="true" />
    </rule>