Archive for tag: SEO

Retrieving WhoIs information via .Net

Retrieving WhoIs information for domains via code is a relatively straight forward process with only one catch, you have to find the right WhoIs server to query.

Luckily I have found a great WhoIs Server List produced by Nir Sofer which lists the top level domains and their server.  The list is available for download here.

The code for retrieving the WhoIs query result is below:

string whoisServer = "";
string ret = "";
Socket s = null;

s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Connect(new IPEndPoint(Dns.Resolve(whoisServer).AddressList[0], 43));

s.Send(Encoding.ASCII.GetBytes(domain + "\r\n"));
byte[] buffer = new byte[1024];
int recv = s.Receive(buffer);
  while (recv > 0)
  {
    ret += Encoding.ASCII.GetString(buffer, 0, recv);
    recv = s.Receive(buffer);
  }
s.Shutdown(SocketShutdown.Both);

s.Close();
return ret;

Rewrites are not Redirects

One of the best URL rewriting packages for the .Net platform is URLRewriting.net.  This excellent package is shipped with many open-source applications, including umbraco, however a lot of developers often fail to realise that there is a big difference between URL rewriting and URL redirection (both of which this package can do).

With URL rewriting the client browser requests Page A from the server.  The server then looks at it's configuration file and returns the content for a different page. i.e. Page B.  In this scenario the client has requested Page A and has received content which it believes came from Page A.  It knows nothing about the existence of Page B.

With URL redirection however the client browser requests Page A from the server.  The server then returns a 301 (permanent) or 302 (temporary) response to the client along with the new page name (Page B).  The client browser then proceeds to make another request to the server, this time for Page B.

From an SEO perspective, using permanent URL redirection means the search engines should index the correct destination URL, as effectively the server is saying Page A doesn't exist, use Page B instead.

With URL rewriting however it is possible that the server can index both Page A and Page B.  To see this in action, google for the term site:bayshield.com.  In the results you will see links for both /blog?filterby=umbraco and /blog/tag/umbraco.

It is important to note that this is not best practice!  Your site will not be easier to find because Google has 'indexed' two versions of the same page.  So next time you use URLRewriting.net be sure to look at the documentation and determine if it is URL Rewriting or URL Redirection you are after.

A more indepth look at 301 redirects

I am always surprised by how much confusion surrounds redirects and how many IT departments say they "cannot be done" due to technical limitations.

There are two basic types or redirect:

  • Permanent - 301
  • Temporary - 302

From an end users point of view both of these redirects will achieve the same result, i.e. the user will enter the URL for page A and will be presented with page B (in both the browser and the address bar).

The big difference between these is how they are interpreted by the search engines.  A 301 redirect indicates that the change is permanent and the search engines will update their indexes accordingly.  This means that the value of the links coming into page A will be attributed to page B.

302 redirects on the other hand tell the search engines that the change is temporary and as such the value of the links is not transferred to page B.

The only other thing to take into account with redirects is whether they are page level (i.e. Page A -> Page B) or domain level (bayshield.com -> www.bayshield.com).

Setting up a 301 redirect in Apache and IIS (the two major web servers) is quite easy and is shown below.

Apache 301 Redirect

One way to setup a 301 redirect in Apache is to create a mod_rewrite redirect rule, which you can add to either the apache config file or .htaccess file.

A simple 301 page redirect rule looks like:

RewriteEngine on

RewriteRule ^page1\.html$ page2.html [R=301,L]

IIS 301 Redirect

To setup a domain level 301 redirect please refer to my previous post.

To setup a page level 301 redirect, open IIS and expand your site in the treeview until you find the file you want to redirect.  Then right click on the file and select properties which will display the screen below.

IIS 301 File Redirect

Select the 'A redirection to a URL' option and then enter the destination URL which can be on the same domain or a different one.  Finally be sure to select the 'A permanent redirection for this resource' checkbox.  Failure to check this box will result in the redirect being created as a 302 redirect rather than a 301.

Optimising the new Blog4Umbraco package for SEO

The new blog4Umbraco package is an excellent choice for anyone wanting an umbraco powered blogging site.  There are however a couple of small changes that can be made to improve the rankings and click throughs to your site.

The first change I have made is to include a new tab on each DocType called "SEO".  On this tab I have added two items, Page Title and Meta Description.

Screen shot 2010-01-02 at 15.08.14

When Google (or any other search engine for that matter) indexes your site, they typically (but not always) use the value inside the meta description tag as the description shown in the search result, however when no meta description is supplied the search engine will choose what it considers to be the most relevant text.

Search Result

In the example above you can see that because I didn't have a Meta Description tag, Google chose the text from the most recent blog to show in the search result.  There are two potential issues here.  Firstly if you blog on a variety of topics as I do, the description shown may not be related to what the user was searching for, meaning they might skip over your search result to another seemingly more relevant result.

Secondly if you want your page to rank for a particular topic (such as umbraco), having a specific description related to the topic will act as a strong indicator to Google about the purpose/context of the page.

Simply add the following code to the BlogMaster template and add the metaDescription field to your doctypes and you are all set.

<umbraco:Item field="metaDescription" runat="server" insertTextBefore="&lt;meta name=&quot;description&quot; value=&quot;" insertTextAfter="&quot; /&gt;"></umbraco:Item>

SEO Change #2

The other change I like to make is to the Archive page, or more importantly the BlogFullArchive.xslt file.

Find the line that says:

<li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a> <br/>

and then insert the following after:

<xsl:value-of select="data [@alias = 'metaDescription']"/><br />

This helps put a little more content (and context) on the Archive page and is more likely to make it rank strongly.

Google Sitemap

Finally don't forget to add a Google Sitemap to your site and submit it in webmaster tools.

Handling cross domain duplicate content issues

Earlier this month Google posted an update on their website documenting how users could handle cross-domain content duplicate issues.

A good example of where cross-domain content duplication becomes an issue is where a site serves the same content for both the www and non-www versions of the site.  As I mentioned in an earlier post the preferred approach is to 301 redirect one domain to the other.

Sometimes however this is not possible, particularly if you are hosting on a shared server.  In these instances Google and the other search engines have made available the canonical meta tag.  To use this tag simply add a rel="canonical" meta tag in the <head> of your page with the href set to the target page.

As an example if I wanted Google to index the page as http://www.nfltips.org/teams then I would ensure the page had the following canonical meta tag.

<link rel="canonical" href="http://www.nfltips.org/teams"/>

That way if Google navigated to the non-www version of the URL, it would still be indexed with the www prefix.

Creating a Google Sitemap in umbraco

One of the must do tasks for any webmaster is the creation and submission of a sitemap to Google. Submitting a sitemap doesn't guarantee that all the pages in your site will be indexed, however it does make it easier for the search engines to at least find your content, which is particularly important if your site is not structured in a SEO friendly manner.

There are a number of packages in the umbraco forum for creating Google sitemaps, however in this article I will show you how to make your own which we will modify in future articles to form the basis of a News Sitemap and a Video Sitemap.

The google article on creating and submitting sitemaps can be found here.

Step 1

The first step in umbraco is to create a new document type and matching template which we will call "Google Sitemap".  Add one new property to this doc type with an alias of umbracoNaviHide and use the "True/False" datatype.

Step 2

Create a new XSLT file called "Google Sitemap" and paste the following code.  Please note that this code initially came from someone in the umbraco community, however I don't know who so I can't reference them here, also the domain name is hard coded in two locations below which you will need to update.

<xsl:template match="/">
<!-- rendering first level node -->
<url>
<loc>/</loc>
</url>

<xsl:call-template name="drawNodes">  
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1]"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="drawNodes">
<xsl:param name="parent"/>

<xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or      (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and      umbraco.library:IsLoggedOn() = 1)">

<xsl:for-each select="$parent/node [string(./data [@alias='umbracoNaviHide']) != '1' and         @level <= $maxLevelForSitemap]">
<url>
<loc><xsl:value-of select="umbraco.library:NiceUrl(@id)"/></loc>
</url>
<xsl:if test="count(./node [string(./data [@alias='umbracoNaviHide']) != '1' and        @level <= $maxLevelForSitemap]) > 0">  
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:template>

Step 3

Open the Google Sitemap template created in step 1 and paste in the following code.

<%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %><asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server"><?xml version='1.0' encoding='UTF-8'?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><umbraco:Macro Alias="GoogleSitemap" runat="server"></umbraco:Macro></urlset></asp:Content>

Step 4

The final step is to go into the content tree and create a new file.  This can be called anything you want, however you will need to note the filename so you can submit it through webmaster tools.  If you don't have the option of "Google Sitemap" as a valid child node, check to ensure that the parent document type allows the "Google Sitemap" doctype as a child node.

SEO and the WWW subdomain

One of the bigest SEO problems on the net today is the way in which the www and non-www versions of sites are handled, i.e. http://nfltips.org vs http://www.nfltips.org.

In the examples above, NFLTIPS.org is the domain name, and the www in the second example is actually a subdomain.  From a search engines point of view this means that both URLs are considered to be separate sites, and this is where the issue occurs.

When other web users link to your site (a major SEO ranking factor), they may or may not include the www portion.  This means that some links will be attributed to the www site and others to the non-www site.

Luckily this is fairly easy to fix.  Simply choose which URL you want to be your primary site address and then 301 redirect the other URL to the primary site.

Non-WWW site redirect example in IIS

  1. Setup the www version of the site in IIS as normal
  2. Setup a second site in IIS this time without the www (it doesn't matter what folder you point it at)
  3. On the "Home Directory" table select the third checkbox "A permanent redirection for this resource" and then enter the www url in the "Redirect to" box.

Non-WWW IIS Setup

Now Google and the other search engines will attribute the value of your incoming links to a single domain name and you will receive the maximum SEO benefit.