Go Back

URL Rewriting SEO Tweaks (in Sitefinity)

I've been working to learn all of the recommended practices for SEO and I've just found one of them that proved to be useful on a Sitefinity site could be easily implemented via several lines in the web.config.

First let me point out my starting point for this was a post by Scott Guthrie which details a variety of these types of rules that can be set up. I believe this is for IIS7 and up, but I don't see a reference to IIS versions in his post.

Since I have this site on discountasp.net, I don't have access to the normal IIS manager and have to work with their web interface which does not have tools for creating URL rewriting rules.

Following Scott Gu's example, I just installed the URL rewrite module on my local IIS7 and created the rule there. The rule was CanonicalHostName which is templated by a wizard in the IIS Manager. Once I created the rule on my default website, I looked in the web.config and grabbed a copy of what was generated.

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="CanonicalHostNameRule1">
                    <match url="(.*)" />
                        <add input="{HTTP_HOST}" pattern="^scottrozman\.net$" negate="true" />
                    <action type="Redirect" url="http://scottrozman.net/{R:1}" />

Then I simply grabbed the <rewrite> section and added it to the web.config for my site after the <handlers> section. If I add a "www" at the beginning of my URL, it is rewritten back to "scottrozman.net".

I originally was looking at also doing a lower case rule, but later discovered it had broken the listing of blog posts in Sitefinity's editing environment. Here was that code:

<rule name="LowerCaseRule1" stopProcessing="true">
      <match url="[A-Z]" ignoreCase="false" />
      <action type="Redirect" url="{ToLower:{URL}}" />

Again, this rule did not work with Sitefinity!  See my related post on Sitefinity.com

I would suggest creating your page names as lowercase or looking at the LowerCase option offered by the Sitefinity Toolkit.

Also, since this hasn't been tested extensively, I'd recommend caution before adding this to your production web environments. I've just played with it on this site so far, but will probably roll it out to other Sitefinity sites if I don't encounter any other issues.

UPDATE 7/5/2012:

I just performed some tests with the LowerCaseRule in Sitefinity 5.0. I could see that the rule was changing some things to lowercase, BUT major breakage in the back end. Also, tried removing the stopProcessing, so it would default to false and things still broke. I don't have a site with SF 5.0 that would benefit from the CanonicalHostNameRule at the moment, so have not seen the results of that.

  • Facebook
  • Twitter
  • DZone It!
  • Digg It!
  • StumbleUpon
  • Technorati
  • Del.icio.us
  • NewsVine
  • Reddit
  • Blinklist
  • Add diigo bookmark