+1-888-365-2779
Try Now
More in this section

Forums / Suggestions / Redirect URLs without 'www' to with 'http://www...' using Global.asax in Sitefinity websites

Redirect URLs without 'www' to with 'http://www...' using Global.asax in Sitefinity websites

2 posts, 0 answered
  1. Developer
    Developer avatar
    1 posts
    Registered:
    28 Jul 2008
    08 Jul 2009
    Link to this post
    Here's a code snippet to do this

    protected void Application_EndRequest(object sender, EventArgs e)
    {

        if (!(Request.Url.AbsoluteUri.ToLower().Contains("www")))
        {
          Response.Redirect(Request.Url.AbsoluteUri.Replace("http://", "http://www."));
         }

          

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Jul 2009
    Link to this post
    Hello Developer,

    Thank you for sharing this code with us.

    Another good solution is using built in AdvancedUrlRewriter.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered