When you want to enforce https on users and you want to redirect any URL being hit on http to the exact counterpart of https, then usually you do it with some HttpModule written in .NET, or install some URL Redirector module in IIS, or setup a dummy website on http and then use meta refresh tag to send traffic to https. There are many solutions out there which requires some amount of coding skill. Let me show you a zero coding redirection setup.
First, go to the properties of the real website which is now listening on both http and https. Change the http port to something dummy like 8083. This will prevent the website from holding onto port 80.
Now create a new website on an empty folder that has read permission on NETWORK SERVICE account. The new website will have the same host headers as the real one, say omaralzabir.com. But it will listen on port 80 only. It won’t listen on https port 443.
Once created, go to properties and Home Directory tab. And do the following:
Things to do here:
- Select the “A redirection to a URL” option.
- Enter the https://yourdomain.com and then $S$Q. Remember, there’s no trailing slash after the domain.
- Select “The exact URL entered above"”
- Select “A permanent redirection for this resource”
- Set Execute permission to None.
- You can select the same app pool as the original one.
The $S puts the subdirectories. If you have hit http://omaralzabir.com/subdir/anotherdit, $S = /subdir/anontherdir. And the $Q represents the query string. Together, they represent the whole path and query string.