---
title: "redirect non www to www in iis 7 and 8"  
description: "The common use of URL Rewrite is redirecting http://domain.com to http://www.domain.com.  Many people are doing this for search engine optimization (S"  
author: "Anonymous User"  
published: 2018-06-15  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/12953/redirect-non-www-to-www-in-iis-7-and-8  
category: "iis 8.0"  
tags: ["iis", "iis 8"]  
reading_time: 3 minutes  

---

# redirect non www to www in iis 7 and 8

## [Introduction](https://www.mindstick.com/blog/359/iphone-development-introduction):

In this article we will explain how to redirect non www to www by using IIS 7 and IIS 8 with example.

## Description:

The common use of URL Rewrite is redirecting http://domain.com to http://www.domain.com. Many people are doing this for [search engine optimization](https://www.mindstick.com/services/search-engine-optimization) ([SEO](https://www.mindstick.com/services/search-engine-optimization)) so that [search engines](https://yourviews.mindstick.com/view/84292/how-do-search-engines-like-google-and-bing-rank-pages) only see the [one site](https://www.mindstick.com/forum/489/attach-the-same-server-certificate-to-more-than-one-site), rather than two sites. The goal is to set a [permanent](https://answers.mindstick.com/qa/50600/what-is-a-permanent-storage-in-pc) [301 redirect](https://www.mindstick.com/forum/161691/what-is-a-301-redirect).

Let’s get started. First, open IIS [Manager](https://yourviews.mindstick.com/view/84649/how-google-tag-manager-works-in-an-efficient-manner) and select [your website](https://yourviews.mindstick.com/view/85950/why-organic-search-is-the-game-changer-for-your-website) and double-click on the “URL Rewrite” icon.

Next, click on “Add Rules…” from the Actions pane.

Now select blank rule from wizard options and click ok button.

![redirect non www to www in iis 7 and 8](https://www.mindstick.com/mindstickarticle/ba28174d-e6bb-4868-bf4c-215cf7b77eff/images/e70a750f-e2f6-4a02-ac7f-75fd8ccc212d.png)

Now Give your rule “Name”. I’ll call mine “non www to www”.

In the “Using” dropdown box you can choose between Matches the Pattern and Wildcards.

Enter * for the “Pattern”. That means anything qualifies. We’ll use a condition later instead of matching to the URL. (for Matches the Pattern, use .*).

![redirect non www to www in iis 7 and 8](https://www.mindstick.com/mindstickarticle/ba28174d-e6bb-4868-bf4c-215cf7b77eff/images/041941cd-5d8f-459d-974f-ab7eeec95397.png)

Now expand the “Conditions” section and click “Add.

![redirect non www to www in iis 7 and 8](https://www.mindstick.com/mindstickarticle/ba28174d-e6bb-4868-bf4c-215cf7b77eff/images/aa87def1-fe1f-41d6-8910-ca010aa9195e.png)

”. In the “Add Condition” dialogue enter the following details and Click OK.

![redirect non www to www in iis 7 and 8](https://www.mindstick.com/mindstickarticle/ba28174d-e6bb-4868-bf4c-215cf7b77eff/images/c8b8999b-0547-4f81-9afb-c6d44fcf7a33.png)

Finally, it’s time to set the Action.

In the Action section make sure that the “Action Type” is set to Redirect.

For the “Action [Properties](https://www.mindstick.com/blog/673/properties)”, enter http://www.domain.com/{R:0}. The {R:0} retains the existing URL so if someone typed something like http://domain.com/contactus it would retain the contactus as it adds the www.

![redirect non www to www in iis 7 and 8](https://www.mindstick.com/mindstickarticle/ba28174d-e6bb-4868-bf4c-215cf7b77eff/images/54ac7c56-70bb-4c9c-b4f8-7c846a5f8d8d.png)

Finally, Apply the rule and test!

## Using a Text Editor

You can also create this rule manually by adding the following to your site’s web.config.

In the **<system.webServer>** section of your web.config, add the following:

## Wildcards

```
<rewrite>
    <rules>
        <rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
            <match url="*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="domain.com" />
            </conditions>
            <action type="Redirect" url="http://www.domain.com/{R:0}" />
        </rule>
    </rules>
</rewrite>
```

This is just the start to great SEO, but it’s a common step and one that I hope you find helpful.

\

---

Original Source: https://www.mindstick.com/articles/12953/redirect-non-www-to-www-in-iis-7-and-8

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
