0
votes

I create a new iis website which main url is per exemple : www.test.com

I create this rule to my product page :

 <rule name="products" enabled="true" stopProcessing="true"  >

      <match url="^fr/products/([_0-9a-z-]+)/([_0-9a-z-]+)" />

      <action type="Rewrite" url="product.aspx?lan={R:0}&amp;cod={R:1}&amp;lib={R:2}" />

      <conditions logicalGrouping="MatchAny">
        <add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|svg|jpeg|js|flv|f4v)$" negate="true" />
      </conditions>

    </rule>

This url http://www.test.com/fr/products/5858/tomato works fine.

But now it wanted to use different domain extension like that:

http://www.test.fr/products/5858/tomtato

In my DNS http://www.test.com and http://www.test.fr goes on the same ip.

How can i manage this with an rewrite rule ?

1
Is your issue solved? If your issue is solved then I request you to mark the helpful suggestion as an answer. This will help other people who face the same issue.Jalpa Panchal

1 Answers

0
votes

to match the domain name in iis URL rewrite rule you could use server variable {HTTP_HOST}.

<rule name="products" enabled="true" stopProcessing="true">

  <match url="^fr/products/([_0-9a-z-]+)/([_0-9a-z-]+)" />

  <action type="Rewrite" url="product.aspx?lan={R:0}&amp;cod={R:1}&amp;lib={R:2}" />

  <conditions logicalGrouping="MatchAny">
                    <add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|svg|jpeg|js|flv|f4v)$" negate="true" />
                    <add input="{HTTP_HOST}" pattern="^www.test.com$" />
  </conditions>

</rule>