Multiple URL Rewrites

sco gordo 221 Reputation points
2021-04-19T16:28:19.207+00:00

I'm setting an IIS rewrite on one of my sites. The site is accessed through multiple bindings, which are accessed via bookmarks and etc. eg:

I want them ALL to redirect to

Should this cover it?

<rewrite>
  <rules>
    <rule name="Redirect HTTP to HTTPS" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://intranet.contoso.local{REQUEST_URI}" />
    </rule>
  </rules>
</rewrite>

Thanks!

Internet Information Services
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sam Wu-MSFT 5,291 Reputation points Microsoft Employee
    2021-04-20T08:43:24.077+00:00

    Hi @sco gordo

    You can try below rules:

    <rules>  
         <rule name="Redirect HTTP to HTTPS" stopProcessing="true">  
           <match url="(.*)" />  
             <conditions>  
                <add input="{HTTPS}" pattern="^OFF$" />  
             </conditions>  
             <action type="Redirect" url="https://intranet.contoso.local{REQUEST_URI}" />  
         </rule>  
         
        <rule name="https to others" stopProcessing="true">  
            <match url="(.*)" />  
                 <conditions>  
                     <add input="{HTTPS}" pattern="^OFF$" />  
                     <add input="{HTTP_HOST}" pattern="^newsite.contoso.local$" />  
                  </conditions>  
                  <action type="Redirect" url="https://intranet.contoso.local{REQUEST_URI}" />  
         </rule>  
     </rules>  
    
    
      
      
    
    No comments