STS Host and Tech Knowledge base
Search
Close this search box.

How to Redirect website from HTTP to HTTPS on IIS

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.

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).
				
					<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”HTTPS force” enabled=”true” stopProcessing=”true”>
<match url=”(.*)” />
<conditions>
<add input=”{HTTPS}” pattern=”^OFF$” />
</conditions>
<action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” redirectType=”Permanent” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
				
			
  • 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.

Share Article

Related Articles