Convert www. to non www. urls for ASP.Net websites

Ok, redirecting your www. urls to non www. through IIS is a total pain. Using a url rewriter is a good option - but not always available in shared hosting. Here is a quick method if you have a small ASP.Net site or are using master pages.

Just add this code to the Page_Load sub in the master page, or to every page if you aren’t using master pages.

        If Not IsPostBack Then

            'redirect www. to non www.

            If LCase(Request.Url.AbsoluteUri).StartsWith("http://www.") = True Then

                Response.Status = "301 Moved Permanently"

                Dim sNewLocation As String

                sNewLocation = "http://" & Mid$(Request.Url.AbsoluteUri, 12)

                If LCase(sNewLocation).EndsWith("/default.aspx") Then

                    sNewLocation = Left$(sNewLocation, Len(sNewLocation) - 13)

                End If

                Response.AddHeader("Location", sNewLocation)

                Exit Sub

            End If

        End If

the code removes the www. and does a simple 301 redirect, while preserving case etc in the new url.

Come to think of it, now that Google can follow javascript redirects, you could add this code as a javascript sub to your pages. Anyone want to do a live test on their site? :)

MS Bing integrates Travel with their search engine

For Travel Meta Search engines, this doesn’t seem like good news…

Microsoft bought FareCast in April 09, and now it is helping power Bing Travel. I haven’t seen the travel link on the Australian version of Bing, but I am guessing that it won’t be long. Not that I really care what Bing does, but if the integrated travel works for Microsoft, then Google may do the same thing. And that would be news. How many travel sites depend on traffic from Google? What if that dried up?