Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

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

Avatar of trs28
trs28 asked on
Web Languages and StandardsMicrosoft IIS Web ServerWeb ServersSSL / HTTPS
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.

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

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!