How to fix canonical lower case with a 301 redirect on IIS.

A ThatsIT Solutions Tutorial

Search engines treat websites that can be accessed by more than one url, each differing only in letter casing, as if they are two different sites. This results in a reduced ranking for the website. Use this rule template to create a redirect rule that will enforce the use of lowercase letters in the URL.

You should force all URL's to lowercase and you should make sure that all your links point to the lowercase version or your URL to avoid unnecessary 301 redirects, remember that 301 redirects leak link juice.

Using IIS manager

The easiest way to fix canonical issues on Microsoft Windows Servers is using the url-rewire add-in for IIS. If you don’t have the URL rewrite tool you can download it using the Web Platform Installer. If you don't have access to the IIS Manager you can place the code at the bottom of this page directly in the web.config file.

  1. Open your IIS Manager and highlight the website you want to apply the rules to.
  2. Double click url-rewrite.
    Url rewrite
  3. Click add rules from the right menu.
  4. Select enforce lowercase URL's.
    SEO rule templates
  5. Click yes.
    Canonical lowercase rule

Well that was easy wasn’t it, well not so fast, there is a problem with forcing to lowercase, pages often call the WebResource.axd files, we need to allow this occurrence. Files like these are never indexed so it does not matter if they can be reached though different casing.

  • Click add conditions from the right hand menu.
    • Change Condition input to {URL}.
    • Check if input sting should be "Matches the pattern".
    • And the pattern is "WebResource.axd"
    • Check Ignore case.
    Url-rewrite conditions
  • You may add more conditions for other files if needed.

That’s it all done. You can now look in your web.config and see the results.

In the web.config file

            <rule name="LowerCaseRule1" stopProcessing="true">
                <match url="[A-Z]" ignoreCase="false" />
                    <action type="Redirect" url="{ToLower:{URL}}" />
                    <add input="{URL}" pattern="WebResource.axd" negate="true" />