Big SEO Mistake!

July 30th, 2008

We launched a site about a month ago using all the SEO guidelines except the "use the keywords at the url rule". I don't know why, but I never really cared about that rule. If google only cares about good content, why should the url care? Even so, I wanted to do everything by the book, so I added the keywords to the title. My urls were something like this:

Page.aspx?Id=1

It would be hard to change the site structure to use urls like Keyword1/Keyword2/, so I tried a little trick. I supposed that Google just wanted the keywords on the url, google doesn't really care about strucuture, so I changed the urls to add a dummy ref parameter:

Page.aspx?Id=1&ref=Keyword1/Keyword2

Well, that was a quick solution, and it worked like a charm. However, I already had several pages indexed using the old url structure. No problem, I'll just permanently redirect them to the new structure, I tought. And so, I did the following:

C#:
  1. // permanently redirect
  2. HttpContext.Current.Response.StatusCode = 301;
  3. HttpContext.Current.Response.Redirect(theNewUrl);

And the visits sent by Google went like this:

And I didn't know why... maybe it was some re-indexing, the site was fairly recent. But that was strange. I do know that Google penalizes websites with duplicated content. And with my new url structure change, I now had two different ways to access the same page. That could be it, but the permanently redirect should have fixed that. Well, wget to the rescue! Just for curiosity I run:

wget my.website.com

And the output was something like:

...
HTTP request sent, awaiting response... 302 Found
Location: theNewUrl [following]
...

Well, that's problematic, the website was returning a 302 status code, and what it should return was a 301 status code. With this configuration I really had 2 urls for the same page witch Google may have found to be duplicates. My problem was with the redirect code, because Response.Redirect internally sets the status code to 302. I solved it way:

C#:
  1. HttpContext.Current.Response.StatusCode = 301;
  2. HttpContext.Current.Response.AddHeader("Location", theNewUrl);

And now, wget shows the correct information:

...
HTTP request sent, awaiting response: 301 Moved Permanently
Location: theNewUrl [following]
...

I really hope that the website recovers from this. It may take a while, we'll see.