2

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.

0

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>
  • 1
    But the question was: ”will IIS actually support running both http and https on the same port 8000 – HBruijn Sep 27 '18 at 6:19
  • The thing is, I am planning to drop the HTTP bindings so only HTTPS bindings are around. – amsga Sep 27 '18 at 6:20
  • @amsga If you want the redirect to work, you have to still have the HTTP binding otherwise the server won't respond to a HTTP www.example com request. And no, you cannot have both HTTP and HTTPS on the same port. – duct_tape_coder Sep 27 '18 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.