troubleshooting Question

IIS URL Rewrite HTTP to HTTPS w/ Port on Specific Domain

Avatar of trs28
trs28 asked on
Microsoft IIS Web ServerWeb ServersSSL / HTTPSWeb Languages and Standards
10 Comments1 Solution835 ViewsLast Modified:
Hello!  I have a snipped of code that I use in the web.config file of an Azure project to redirect all HTTP requests to HTTPS.  It does so quite gracefully too I might add.

  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Redirect to HTTPS">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          </conditions>
          <action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

However, there are two different domains that could end up having this code applied to it.  For example, we'll say it's www.standardport.com & www.customport.com.   I'm not sure if they're real addresses, but if they are, they're not affiliated with me in any way.   Okay ... so if www.standardport.com is entered, I need the code to run just as it's listed above and simply redirect the URL to HTTPS.   If www.customport.com is entered, I still need it to redirect to HTTPS but also to port 555.  

I know it can be accomplished, but I've been playing with different configurations and can't seem to get the right combination of code to make it work.   Any help is very much appreciated!
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros