3
votes

I want to create a rewrite rule in IIS 8.5 so that the TLD in the url gets changed from .com to .net.

example:

from: http://sub.domain.com/index.aspx?test=123

to: http://sub.domain.net/index.aspx?test=123

At the moment I got something like this in my web.config but is doesn't seem to work:

   <rule name="TLD" enabled="false">
       <match url="(.*)" />
       <conditions>
           <add input="{HTTP_HOST}" pattern="^(www.)?([a-z]*.)(domain)(.com)(/?.*)$" />
       </conditions>
       <action type="Rewrite" url="http://{C:2}{C:3}.net/{C:5}" />
   </rule>

Any suggestions?

1
I tried doing this too, I must've wasted at least an hour trying. I don't think it's possible - it can't be as dynamic as this.harvzor

1 Answers

0
votes

I was looking for the exact same problem and found this

 <rule name="WWW" enabled="true" stopProcessing="true">
     <match url=" (.*)"/>
     <conditions >
        <add input="{HTTP_HOST}" pattern="^(www\.)?example\.old$"/>
     </conditions>
     <action type="Redirect" url="h++p://example.com/{R:1}" redirectType="Permanent" />
 </rule>

Found it here: ReWrite top-level domain (TLD)