6 SEO Tips For ASP.NET URL’s

If you are building a new ASP.NET application, SEO has become a big factor in how you plan the structure / code of the site.  But quite an important part of the site which are often overlooked are the URL’s, and a lot of people do the basics which I’ll show below but there are a few common things people tend to miss or never thought could be a problem. I use ISAPI rewrite for most of my sites, which is an amazingly effective tool for sorting duplicate content and SEO issues which I’ll show below

1.) Rewrite your URL’s to be useful / descriptive and stick away from using the old dynamic way

i.e. mypage.aspx?e=54&b=99

Google even tell you this is not ideal in the webmaster guidelines (See bottom of Design & Content Guidelines section) - http://www.google.co.uk/support/webmasters/bin/answer.py?answer=35769&hlrm=en_uk [more]

 

2.) Strip our non alpha numeric characters from the URL and use Hyphens to separate words

Regex.Replace(strInput, "[^\w]", "-")

 

3.) Replace & (Ampersands) in URLS with the word ‘and’ so a page called ‘Microsoft & Google’ might have a URL like

microsoft-and-google.htm

I use this function to rewrite my URL’s

Function CreateURLs(ByVal strInput As String) As String strInput = strInput.Replace("&", "and") strInput = Regex.Replace(strInput, "[^\w]", "-") strInput = strInput.Replace("----", "-") strInput = strInput.Replace("---", "-") strInput = strInput.Replace("--", "-") If strInput.EndsWith("-") Then strInput = strInput.Substring(0, strInput.Length - 1) End If strInput = LCase(strInput) Return strInput End Function

 

4.) Try to keep away from using URL’s that have multiple folders, as it

/Home/Something/this/that/12/

If you have to have your URL’s like this then at least make them as short as possible, descriptive and stick away from numeric's like

/Cat14/SubCat77/521

Try to use URL’s that makes sense, the new Whitehouse site is a good example of how to use this type of URL rewriting effectively

http://www.whitehouse.gov/about/presidents/johnfkennedy/

 

5.) Turn your pages into .htm/.html extensions instead of .aspx with ISAPI Rewrite – This little trick just tells ISAPI to treat .htm files as .aspx files.

RewriteEngine on RewriteRule ^(.*)\.htm $1\.aspx

There is no written evidence that changing your extension to .htm from .aspx will help your SEO – But personally from running a few successful stores and sites, the sites with the .htm extensions pages just ‘seem’ to do a lot better in the SERPS.

TIP!: In case you need to have a folder that doesn’t treat .htm files as .aspx you can add this to ISAPI (The middle line)

RewriteEngine on RewriteRule ^FolderToIgnore/ - [L] RewriteRule ^(.*)\.htm $1\.aspx

Tip of the hat to iamlost on cre8asite for this gem

 

6.) Keep your URL’s lowercase and 301 redirect any non lowercase URL’s (using ISAPI rewrite)

RewriteEngine on RewriteMap lc int:tolower RewriteCond %{REQUEST_URI} [A-Z] RewriteRule (.*) ${lc:$1} [R=301,L] RewriteRule ^(.*)\.htm $1\.aspx

This is to stop duplicate content and if anyone has linked to you via an uppercase URL, as still the search engines seem to be treating the same page with different case letters as two different pages – So Default.htm & default.htm can be seen as separate pages! Crazy… I know…!

 

7.) And a free seventh tip… Well its not really an SEO / URL related tip, but get yourself signed up and site registered with the Google Webmaster Tools

kick it on DotNetKicks.com Shout it

6 comments for “6 SEO Tips For ASP.NET URL’s”

  1. Gravatar of TommyTommy
    Posted Tuesday, March 10, 2009 at 12:10:38 PM

    I don't like one part of your code for replacing multiple dashes. I know it is unlikely, but you should really put this.

    do
    {
    strInput.Replace("--", "-")
    }
    while (strInput.Contains("--"))

  2. Posted Tuesday, March 10, 2009 at 1:05:48 PM

    Thanks for your comment Tommy and you are completely right :)

  3. Gravatar of CarstenCarsten
    Posted Tuesday, March 10, 2009 at 6:50:05 PM

    Why loop, when you can regex replace "([-]+)" with "-" =)

  4. Gravatar of jonathjonath
    Posted Tuesday, March 10, 2009 at 7:54:28 PM

    Is there a reason why your blog does not follow rules 4, 5, and 6? :-)

  5. Gravatar of JasonJason
    Posted Tuesday, March 10, 2009 at 8:16:18 PM

    I was gonna suggest: ([-]{2,})

  6. Posted Wednesday, March 11, 2009 at 6:46:11 AM

    @ Jonath - Indeed its BlogEngine out the box and I didn't do them in the beginning so its pointless doing them now

Post a comment