Redirect from one domain to another domain

theampark 21 Reputation points
2021-10-26T16:45:34.033+00:00

Hi,

I want to redirect test.edwardsite.com to edwardsite.com/test.

I tried the following rules, but it doesn’t work, I am new to iis, can someone help me?

<rewrite>
<rules>
<rule name="edward rule" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^test\edwardsite\com$" />
</conditions>
<action type="Rewrite" url="http://edwardsite.com/test" />
</rule>
</rules>
</rewrite>

Windows development | Internet Information Services
0 comments No comments
{count} votes

Accepted answer
  1. Sam Wu-MSFT 7,561 Reputation points Microsoft External Staff
    2021-10-27T02:55:34.807+00:00

    @theampark

    You can try this rule:

     <rule name="test" stopProcessing="true">  
            <match url=".*" />  
                 <conditions>  
                       <add input="{HTTP_HOST}" pattern="^test\.edwardsite\.com$" />  
                       <add input="{REQUEST_URI}" pattern="^\test" negate="true" />  
                 </conditions>  
            <action type="Rewrite" url="http://edwardsite.com/test/{R:0}" />  
     </rule>  
    

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.