Redirect website to HTTPS on IIS
Firstly, make sure that you have an SSL certificate already installed. After that to Configure IIS7 ,IIS8 to force using HTTPS for website, follow the steps:
- Download and install the IIS URL Rewrite Module.
- Open IIS Manager, in the console select the website you want to redirect.
- Select URL Rewrite.
- Click Add Rules.
- Select Blank Rule, click OK.
- Enter the Name of rule.
- In the Match URL section choose “Matches the Pattern” in the Requested URL drop-down.
- Next select “Regular Expressions” in the Using drop-down.
- Enter: “(.*)” in the Match URL section.
- In the conditions section, select Match All under Logical Grouping, the click Add.
- In the next window:
Enter {HTTPS} as the condition input.
Select “Matches and Pattern” from the drop-down, Enter ^OFF$ as the pattern, Click OK. - In the Action section, click Redirect and then specify the Redirect URL as: https://{HTTP_HOST}/{R:1}
13.Check the Append Query String box. - Choose your redirection type (301).
- Click Apply.
After that , you’ll have to apply the rule to your website.
Note
The Require SSL is NOT checked under SSL Settings for your website.
Setting up IIS HTTP to HTTPS Redirect Rules
- In the IIS dashboard, right click on your site and select Explore.
- Your Root Directory will open, select the web.config file and open it.
- Make sure the file contains the following code block (if not, add it).
- If you haven’t web.config file in your root directory, create new .txt file, just place the above code in it, save and then rename the file to web.config.
- Finally, when you check your website by entering www.youdomain.com in the browser, It should redirect to the https version.
Note
These above steps to redirecting IIS from HTTP to HTTPS works with IIS 5, 6, 7, 8, 8.5, and IIS 10.