Category Archives: SEO

ASP.NET MVC Whole Site 301 Permanent Redirect

For some reasons, we need to permanently redirect the whole website to another website. It would be much easier that you are the owner of the server. But most of time you just host your website on the server out there. It wouldn’t be a big problem that your hosting company will support you to do some simple 301 redirect or may you have enough privilege to do it yourself. Is it possible to redirect permanently the website to other website by programming a little bit?

Sure you can. With MVC routing facilities, you can define your customized redirect logic: CREATE AN EMPTY MVC PROJECT, MODIFY GLOBAL.ASPX.CS FILE ONLY ON THIS EXAMPLE:

First of all, define two objects which implemented IRouteHandler and IHttpHandler, you can feel free to define those two objects on Global.aspx.cs file:

//@Implements IRouteHandler
class RedirectRouteHandler : IRouteHandler
private string newUrl;
public RedirectRouteHandler(string newUrl) { this.newUrl = newUrl; }
public IHttpHandler GetHttpHandler(RequestContext requestContext)
return new RedirectHandler(newUrl);

//@object implements IHttpHandler
class RedirectHandler : IHttpHandler
private string newUrl;

public RedirectHandler(string newUrl) { this.newUrl = newUrl; }

public bool IsReusable { get { return true; } }

public void ProcessRequest(HttpContext httpContext)
httpContext.Response.Status = “301 Moved Permanently”;
httpContext.Response.StatusCode = 301;
httpContext.Response.AppendHeader(“Location”, newUrl);

Then add one line on RegisterRoutes(RouteCollection routes) method (in Global.aspx.cs):

routes.Add(new Route(“{*pathInfo}”, new RedirectRouteHandler(@””));

Now all request to the website will redirect to “” permanently. :)

SEO tips

ecently I was assigned to optimize a website for search engine recognization.  Here are some points which I think should be important to optimization.

1. Not Keywords But Keyphrase

In some books and some readings,  they encourage optimizing keywords first. Actually, I think first to do is not to arrange “keyword” but keyphrase. There are tonnes of keywords which are ignored by search engine, what make you think google prefer your words? The different between keywords and keyphrase is that keyphrase is oganic group of several keywords, better group in meaningful phrase. For instance, “melbourne, cellphone, nokia” should be re-group to “melbourne nokia cellphone”. it is said that 3-4 words phrase is effective and thrift. You can have several keyphrases.

2. Don’t use image navigation nor javascript 

unfortunately, search engine is not eligible to read the contents from image even flash. If you insist using images as navigation menu, don’t forget to add “alternative” to the image tag.  I prefer UL and LI plus image listing type to represent navigation menu.

3. Wrap product name or article name in H1 (H2, H3…)

That’s also a way to increase readable by search engine.  Also don’t forget to mention more keywords as possible inside the HTML BODY section.

4. Use meaningful URL

Thanks to many SEF utilities. They provides URL-rewrite capablity for web server. Those techniques can easily turn your URL “http://xxx?id=yyy&title=zzz” to “http://xxx/title-zzz_id-yyy” in a breath. Actually web server like Apache provides url-rewrite module that you can add the rewrite rules to the website by yourself.

5. Re-consider where and how AJAX is performed

AJAX is a great method to improve user’s experience of your website. But it comes with some short-comings. If you render your web contents all by AJAX, search engine will stop indexing your page. Like I said on the point 2, search engine will not be smart enough to execute your javascript.  So I think AJAX will be good when you:

  • Proceeding user’s feedback on the page (such as  post comments and re-render the comments).  
  • Add to shopping cart behavior. 
  • Performing some post data validations, such as checking availability of user name on register page.
  • Interacting with user on management pages, for instance, user information or user account management page. Since those pages should not be crawled by web-spiders. You can use javascript arbitrarily. But still keep in mind that NEVER force the page to be javascript support ONLY, i mean don’t force user to see the page only if javascript is enable.