This will automatically redirect visitors from http:// to https:// (secure).
Read this first
Do NOT paste the entire example into an existing file.
You are only adding one rule.
Step 1 — Open or create web.config
The file must be named web.config and located in your website’s main folder (same place as index.php / default.aspx).
To access your files:
• Use FTP and open your website root folder, OR
• Log in to your control panel → File Manager → open your site root.
If web.config does not exist, create a new file and paste the FULL example from Step 2A.
If web.config already exists, follow Step 2B instead.
Step 2A — If web.config is NEW (empty file)
Paste this FULL content into the file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect"
url="https://{HTTP_HOST}{REQUEST_URI}"
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Save the file. You are done.
Step 2B — If web.config ALREADY HAS CONTENT
You are ONLY adding the rule below.
Do NOT paste the full example.
Find this section in your file:
<rewrite>
<rules>
Paste ONLY this rule inside the <rules> section:
<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect"
url="https://{HTTP_HOST}{REQUEST_URI}"
redirectType="Permanent" />
</rule>
Save the file.
Step 3 — Test
Open your site using http://
It should automatically redirect to https://
If it does not work
• Make sure SSL is installed on your site
• Make sure the file name is exactly web.config
• Make sure you added the rule inside <rules> (not outside)