Knowledgebase

Domain Redirection in IIS (Windows Server) Print

  • 0

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.comhttps://example.com
www → non-www http://www.example.comhttps://example.com
non-www → www http://example.comhttps://www.example.com
One domain to another example1.comexample2.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

  1. Open IIS Manager → Select your website.

  2. Open URL Rewrite (install if not present).

  3. Click Add Rules → Select Blank Rule → Click OK.

  4. 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/pagehttps://domain.com/page

  • Preserve query strings and SEO rankings


Method 2: IIS Site-Level Redirection (Simple Use Case)

For simple redirection (e.g., domain1.comdomain2.com):

  1. In IIS Manager, select the site (e.g., domain1.com).

  2. Open HTTP Redirect.

  3. Check: "Redirect requests to this destination"

    • Enter: https://www.domain2.com

  4. 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:

xml
CopyEdit
<configuration> <system.webServer> <rewrite> <rules> <rule name="Redirect to HTTPS and non-www" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> <add input="{HTTP_HOST}" pattern="^www\.(.+)$" /> </conditions> <action type="Redirect" url="https://{C:1}/{R:1}" redirectType="Permanent" /> </rule> </rules> </rewrite> </system.webServer> </configuration>

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

Was this answer helpful?
Back