IIS – How to Redirect URL from HTTP to HTTPS on Same Port

httphttpsiis-8.5

I have a website located on a custom port number in the server.
Currently, it is serving the users using HTTP.

I was wondering if it is possible to redirect from HTTP to HTTPS while still reusing the same port number in IIS.
E.g http://www.example.com:8000 becomes https://www.example.com:8000

Some of the information I have seen is that I need to use a second binding.
E.g. Bind port 80 for HTTP and 443 for HTTPS and then do a redirect for port 80.

Best Answer

I don't know what version of IIS you are using but if it is IIS7/7.5 then IIS URL REwrite will do just fine.

Here is a rule to copy into your root web.config

URL REWRITE

http://www.iis.net/download/urlrewrite

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
  <match url="(.*)" />
    <conditions>
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
 <add input="{SERVER_PORT}" pattern="^1000$" /> 
    </conditions>
  <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}:1443/{R:1}" />
</rule>