Aug
6
Written by:
Javier Callico
8/6/2010
I’ve been working on making callicode.com more friendly to search engines. One of the first things to do when trying to improve you site’s ranking is to make sure that your content is only available from a unique URL otherwise it can be considered duplicate content and your site penalized (more details here and here). Since most websites are configured to work with and without the www prefix you have to decide which one is going to be your site’s main domain and redirect all other requests accordingly preferable using a 301 redirection.
I decided that callicode.com was going to be the main domain and started looking for ways to get it done with minimal effort.
First I tried to find a possible built in functionality on DotNetNuke, which is the engine powering callicode.com. Up until version 05.04.04 this functionality is not supported. There are some commercial plug-ins specialised in SEO advertising such functionality but I did not wanted to follow that path since I was sure there was a free alternative out there.
Next I downloaded and configured UrlRewriter.Net. After trying for a while I gave up since couldn’t get the proper redirection to work.
My next option was Managed Fusion URL Rewriter a URL manipulation engine based on the Apache mod_rewrite extension which works as a HTTP Module on your existing .NET site, was easy to configure and got the job done.
Only the following steps are required:
1- Download and unzip the file provided.
2- Copy ManagedFusion.Rewriter.dll to your site’s bin folder.
3- Modify your site’s web.config to include the following sections:
<configSections>
<section name="managedFusion.rewriter" type="ManagedFusion.Rewriter.Configuration.ManagedFusionRewriterSectionGroup"/>
</configSections>
<system.web>
<httpModules>
<add name="RewriterModule" type="ManagedFusion.Rewriter.RewriterModule, ManagedFusion.Rewriter"/>
</httpModules>
</system.web>
<managedFusion.rewriter xmlns="http://managedfusion.com/xsd/managedFusion/rewriter">
<rules engine="Apache" />
</managedFusion.rewriter>
4- Create a file named “ManagedFusion.Rewriter.txt” on the root of your site with the following content:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.callicode.com$ [NC]
RewriteRule ^(.*)$ http://callicode.com$1 [R=301,L]
And that’s it. You can verify that any request under http://www.callicode.com/ is now redirected to the equivalent URL without the www prefix.