Redirecting domains in IIS is essential for SEO, security, and UX — whether it's from http → https
, www → non-www
, or one domain to another. Below is a complete technical playbook for handling redirection scenarios in IIS.
Common Redirection Use Cases in IIS
Redirect Type | Example |
---|---|
HTTP → HTTPS | http://example.com → https://example.com |
www → non-www | http://www.example.com → https://example.com |
non-www → www | http://example.com → https://www.example.com |
One domain to another | example1.com → example2.com |
Folder-level redirects | /oldpage → /newpage |
✅ Pre-Requisites
-
IIS URL Rewrite Module installed
Download here -
Website already added in IIS
Method 1: Using IIS URL Rewrite Module (Best Practice)
Step-by-Step: Redirect http → https
+ www → non-www
-
Open IIS Manager → Select your website.
-
Open URL Rewrite (install if not present).
-
Click Add Rules → Select Blank Rule → Click OK.
-
Name the rule:
Force HTTPS and non-www
.
In Conditions:
-
Click Add Condition
-
Condition input:
{HTTPS}
-
Check if input "does not equal"
ON
-
-
Click Add Condition
-
Condition input:
{HTTP_HOST}
-
Check if input "matches the pattern"
^www\.(.*)$
-
In Action:
-
Action type: Redirect
-
Redirect URL:
https://{C:1}/{R:1}
-
Redirect type:
Permanent (301)
✔ This will:
-
Redirect all
http://www.domain.com/page
→https://domain.com/page
-
Preserve query strings and SEO rankings
Method 2: IIS Site-Level Redirection (Simple Use Case)
For simple redirection (e.g., domain1.com
→ domain2.com
):
-
In IIS Manager, select the site (e.g.,
domain1.com
). -
Open HTTP Redirect.
-
Check: "Redirect requests to this destination"
-
Enter:
https://www.domain2.com
-
-
Check:
-
"Only redirect requests to content in this directory"
-
"Status code":
301 Permanent
-
⚠ This will redirect all traffic from that IIS site to the new domain. Ideal for full-site migration.
Method 3: web.config
File Redirection (Advanced Control)
Manually edit the web.config
in the site root:
Test the Redirection
Tool | Purpose |
---|---|
Browser | Manual testing |
curl -I http://yourdomain |
View HTTP status codes |
SEO Tools (Ahrefs, Screaming Frog) | Check 301 redirect mapping |
Redirect Checker | Online HTTP trace |
Best Practices
-
Always use 301 Permanent redirects for SEO.
-
Don’t create infinite loops: avoid double bindings (e.g., www/non-www both active without condition filters).
-
Keep web.config clean and versioned.
-
Validate redirection chain is single-hop, not multi-hop.
Summary Table
Scenario | Method | Module Needed |
---|---|---|
http → https |
URL Rewrite (Rule) | URL Rewrite |
www → non-www |
URL Rewrite with regex | URL Rewrite |
domain1.com → domain2.com |
HTTP Redirect (site-level) | No extra module |
Complex redirects | web.config |
URL Rewrite |