Some SEO rules regarding Sitefinity

Recently I was trying out some IIS Rewrite Rules to optimize my Sitefinity websites. Some of these rules are very effective in making your website SEO proof.

  • December 5, 2018

Background information

Recently I was trying out some IIS Rewrite Rules to optimize my Sitefinity websites. Some of these rules are very effective in making your website SEO proof. 

I’ll name three of them here to get started. I’ll show how to add these rules into your web.config. You can also use the IIS Rewrite module to let IIS add the rules to your web.config. Canonical names When setting up new websites in IIS you specify which host names map to your site. This is called Bindings in IIS terms. 

Usually this is at least two: www.example.com and example.com, sometimes even more. The reason this is important for SEO purposes is that search engines treat all URLs differently, so when you have two or more URLs all pointing to the same content your search ranking will suffer. To fix this we want to have a primary hostname configured. The following rule is redirecting konstrui.nl to www.konstrui.nl and of course all request that are beginning without www:

<rule name="Canonical Hostnames">
   <match url="(.*)" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
         <add input="{HTTP_HOST}" pattern="^www\.konstrui\.nl$" negate="true" />
      </conditions>
      <action type="Redirect" url="http://www.konstrui.nl/{R:1}" />
</rule>

Trailing slashes
Same story we have with adding or removing trailing slashes. A URL could have lot’s of combinations:

- www.konstrui.nl
- www.konstrui.nl/
- konstrui.nl
- konstrui.nl/ 

So, it is could to pick one format and stick with it. I prefer to remove the trailing slash at the end. To remove the trailing slashes we could do something like this:

<rule name="Remove trailing slashes" stopProcessing="true">
   <match url="(.*)/$" />
   <conditions>
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
   </conditions>
   <action type="Redirect" url="{R:1}" />
</rule>

Default document and Homepage
This is a more specific rule as some CMS systems or websites handle this differently. Regarding Sitefinity, we have to deal with this issue. When you browse to www.konstrui.nl you will get the homepage served and the URL doesn’t change. When you click on the home link from the navigation menu, you see the URL changes to www.konstrui.nl/home. This is because every page inside Sitefinity needs to have an URL name. You can’t add pages through the UI without a URL name. This URL name is what makes a page unique in the Sitefinity website.

So what we want is that if visitors browse to our homepage they always and up with this URL: www.konstrui.nl To do this, we can add the following rule:

<rule name="Remove default documents" stopProcessing="true">
   <match url="(.*)" ignoreCase="true" />
   <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
      <add input="{REQUEST_URI}" pattern="^\/home$" />
      <add input="{REQUEST_URI}" pattern="^\/default.aspx$" />
   </conditions>
   <action type="Redirect" url="http://www.konstrui.nl" appendQueryString="false" redirectType="Permanent" />
</rule>

Credits to Stephen Pittman for pointing me to the last solution.


Image Description

Daniel Plomp

Entrepreneur, Senior Software Engineer .NET, Sitefinity Solution specialist, Orchard CMS enthusiast, Product Owner

All Author Posts

Got another minute? Check out:

Image Description

Call us

+31 (0) 36-2000196
Image Description

Address

Grote Beer 57, 3893 DJ Zeewolde
NLThe Netherlands

Please sign in

Signin to manage your account.

Do not have an account? Signup

OR