Rules

Secret ingredients to quality software

Do you fix your ugly URL's?

Last updated by Tiago Ara├║jo [SSW] on 15 Mar 2021 04:23 am (9 months ago) See History

Ugly URL's don't only make it difficult for users to browse your site, they can also impact your Google rankings.

northwind.com/MyInternalDB/UserDatabase/ProductList.aspx?productname=Access

Figure: If you have a nasty URL like this...

You should fix it up to look more like this:

northwind.com/products/access

Figure: Users could even guess the URL

  1. Add in Global.asax a route
protected void Application_Start(object sender, EventArgs e) 
{ 
//RouteTable and PageRouteHandler are in System.Web.Routing 
RouteTable.Routes.Add("ProductRoute", new Route("products/{productname}", new PageRouteHandler("~/MyInternalDB/UserDatabase/ProductList.aspx.aspx"))); 
}

Figure: OK example - create a static route if you only have a few rewrites

  1. Use the URL Rewriting Module for IIS7

IIS7Rewrite
Figure: Good example - An IIS7 Rewrite is much easier to manage

Adam CoganAdam Cogan
Camilla Rosa SilvaCamilla Rosa Silva

We open source. Powered by GitHub