IIS / ASP.NET Url Rewriting Multiple Domains

Problem

I’m hosing a website using Microsoft Azure websites. I’m rebranding it and need to perform 301 redirects on a few domain names.

Solution

The solution is simple; use the URL rewriting modules of IIS by adding the rules to the web.config:

  <system.webServer>
	<rewrite>
		<rules>
			<rule name="SmoochiepetsToAnimalGuardian" stopProcessing="true">
				<match url=".*" />
				<conditions logicalGrouping="MatchAny">
					<add input="{HTTP_HOST}" pattern="^(www.)?smoochiepets.(com|net)$" />
					<add input="{HTTP_HOST}" pattern="^(www.)?smoocheypets.(com|net)$" />
					<add input="{HTTP_HOST}" pattern="^(www.)?smoochypets.(com|net)$" />
				</conditions>
				<action type="Redirect" url="http://www.animalguardian.net/{R:0}" redirectType="Permanent" />
			</rule>              
		</rules>
	</rewrite>
 </system.webServer>

Reference

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s