22 March, 2014

URL Redirection / Vanity URL in IIS 7.5

We have a SharePoint site like www.sampleportal.com. Whenever user types the any word (eg. "employee”) after site name (www.sampleportal.com/employee) , it should redirect to another site www.employeeportal.com .

We can achieve this in two ways.
1.Using IIS URL Rewrite. [OR]
2.Adding URL redirect rule in Web.config file manually.

Method 1:Using IIS URL Rewrite

1) Open IIS Manager.
2) Under sites, select your site.
3) Under IIS section , you can see a module called “URL Rewrite”.
    If you are not able to see that module , you can download & install it from

4) Click on “Add Rule(s)” and select “Blank Rule”. Click on “OK”.

5) There will be four section which you need to fill.
a)      Name of the rule: You can provide a name for this rule Eg)”ReDirect To Employee Portal”.
b)      Pattern : In our case , it should match the word “employee”. So we can provide the pattern like “^employee$
c)      Conditions: Add the condition like base URL should be www.sampleportal.com .
 Set Condition Input: {HTTP_HOST} & Pattern “^www.sampleportal.com$
d)      Action: Set action type as “Redirect” & in Redirect URL provide the URL which you want to  redirect  “www.employeeportal.com”.


6) Click on “Apply” .

This method will add URL redirect rule in Web.config file automatically once we click on “Apply”.( We can add/edit/disable/remove the rule whenever needed via IIS URL Redirect)

Method 2: Adding URL redirect rule in Web.config file Manually.
(We need to be careful while doing changes to web.config file manually. Always take backup of web.config file before doing any modification’s)

Add the Below Rule  inside  <system.webServer> tag.
<rewrite>
     <rules>
             <rule name="ReDirect To Employee Portal">
                    <match url="“^employee$" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^www.sampleportal.com$" />
                     </conditions>
                     <action type="Redirect" url="www.employeeportal.com" />
               </rule>
      </rules>
</rewrite>

Now it’s all set. Whenever user's hits the URL “www.sampleportal.com/employee” , it will redirect to www.employeeportal.com.

2 comments:

Your feedback is always appreciated. I will try to reply to your queries as soon as possible- Amol Ghuge