Friday 5 January 2018

IIS redirect from HTTP to https

We recently faced an issue relating to URL Rewriting on our IIS 8 SharePoint 2013 server.
Firstly I would like to let you know the website current situation in which it was working.
Web Application was hosted on port 80 but after some configuration, it was moved to port 443 and port 80 was discontinued.
In addition, under SSL settings  require SSL was checked so the website can be only browsable when user upfront tries to browse via https://www.xyz.com by typing in the URL bar

When the user was trying to access http://xyz.com or https://xyz.com or http://www.xyz.com, it wasn't accessible at all and it was hampering the current SEO operations of our SharePoint 2013 web application in google.
Furthermore, We attempted all the permutation combinations of redirection to get it worked from HTTP to https when the user tries to access the website.

So, mentioned below are the permutation combinations as follows:
1. Defining New rules for redirection in URL rewrite tag of web.config file of SharePoint 2013 web application.
2. We reconfigured alternate access mapping.
3. Under SSL settings, we un-check require SSL option.
4. Under Http redirect, we tried all the options of redirect all the request to https://www.xyz.com but no relief.
5. A very childish option of letting the user visit the URL http://www.xyz.com and redirecting again to https://www.xyz.com via jquery/javascript

After spending the whole day behind the issue. We were left with no option to go with "No 5" for redirection from HTTP to https.
As leaving things behind we thought to give a try of re-installation of the setup.
1. press (windows + r) key  and it will open run
2. type appwiz.cpl and it will open control panel
3. under Programs and features, we repaired the "IIS URL rewrite option"
4. After repairing the module the IIS gets reset
5. We tried to browse the website using http://www.xyz.com and it redirected to https://www.xyz.com

After all the tantrums, the issue was fixed by repairing the IIS rewrite under control panel.

References:
Download URL Rewrite
Redirect from HTTP to HTTPS using the IIS URL Rewrite module
Redirect a user from HTTP to HTTPS using JavaScript