iis7 rules to improve seo

3 IIS URL rewrite rules for improved SEO

When moving a website or a blog there are several things that need to fall in place in order to make the transition as smooth as possible. Search Engine Optimization (SEO) sits high on the priority list. So we put together this article to help you out with some of the tricky aspects.

Before going further, I must inform you that this article only applies to those hosting their sites on Windows.

For this task, since my application servers run IIS 7, I decided to give its freely distributed URL Rewrite extension a fair shot at solving our URL change shot. For your convenience, Microsoft has made the extension available through the Microsoft Web Platform Installer, so getting it up and running is a snap.

Once installed, open the IIS Manager where you should now see the newly installed extension under each of your websites (URL Rewrite).

In this blog post I will be discussing the 3 rules that I consider the most important when it comes to ensuring that your content is being indexed efficiently.

The screen shot below shows the list of rules as displayed in IIS Manager after they have been defined.

1. Convert/Force URLs to Lower Case

URLs can be defined in both uppercase and lowercase characters. What this means is that https://www.maxiomtech.com/tips-tricks/reorganize-and-rebuild-indexes-in-sql-server/ is treated as a different page than https://www.maxiomtech.com/tips-tricks/Reorganize-And-Rebuild-Indexes-In-SQL-Server/ by a search engine, even though they point to the VERY SAME resources and content. The best way to handle this issue is to REWRITE the URL to lowercase and respond to the “old” capitalized version with am HTTP 301 response (Permanently moved).

Here is the rule:

[code lang="xml"]<rule name="Convert to lower case" stopProcessing="true">
	<match url=".*[A-Z].*" ignoreCase="false" />
	<action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
</rule>[/code]

Below is a screen shot of the Edit Rule UI in IIS for the lower case enforcement rule:

2. Enforce Canonical Host Names

Similar to what we described above, search engines will treat https://www.maxiomlabs.com and https://maxiomlabs.com as two separate websites. Search rankings are surely going to drop, given that search engines believe that 2 sites should share the benefit of having the same content.

Once again, the solution is quite simple: HTTP 301 Redirect https://maxiomlabs.com to https://www.maxiomlabs.com.

Note that the rule below includes additional conditions for the maxiomlabs domain name, which also points to this website. In this case, I added two additional conditions where I HTTP 301 redirect all requests to inspectorit.com whether prefixed with a www. or not.

[code lang="xml"]
<rule name="Canonical Host Name" stopProcessing="true">
	<match url="(.*)" />
		<conditions>
			<add input="{HTTP_HOST}" negate="true" pattern="^inspectorit.com$" />
			<add input="{HTTP_HOST}" negate="true" pattern="^inspectorit.com$" />
			<add input="{HTTP_HOST}" negate="true" pattern="^inspector.it$" />
		</conditions>
		<action type="Redirect" url="https://www.inspectorit.com/{R:1}" redirectType="Permanent" /> </rule>
[/code]

3. Even More Canonical Host Name

Similar to what we described above, search rankings will suffer and drop, if search engines believe that 2 sites share the same content.  Incidentally, search engines also think that https://www.maxiomlabs.com and https://maxiomxlabs.com/default.aspx are two separate websites. The right thing to do here, is HTTP 301 redirect the default.aspx page to https://www.maxiomlabs.com by applying the following rule.

[code lang="xml"]
<rule name="Canonical Host Name - Redirect Default.aspx" patternSyntax="Wildcard" stopProcessing="true">
	<match url="default.aspx" />
	<action type="Redirect" url="/" redirectType="Permanent" />
</rule>
[/code]

All rules described above are applied to this website in one way or the other. Go ahead, give it a shot.

More information and reference for version 2.0 of the URL Rewrite extension can be found here: https://learn.iis.net/page.aspx/665/url-rewrite-module-20-configuration-reference/