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

Forums / Developing with Sitefinity / Rewrite non-www

Rewrite non-www

3 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    08 Nov 2010
    Link to this post
    Hi,

    The SiteFinity Rewrite only appears to work with the part of the URL after the domain name, is that right?

    I am trying to redirect from mydomain.com to www.mydomain.com which is extremely important for SEO purposes. Can this be done?

    I tried:
    <url>^mydomain\.com</url>
    <rewrite>www\.mydomain\.com</rewrite>

    But this didnt work at all.

    Thanks
    higgsy
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    08 Nov 2010
    Link to this post
    Hello higgsy,

    This cannot be done with the Sitefinity Url Rewrite module. The UrlRewrite module works with (relative) paths starting after the domain name so it will not detect whether you are using www or not. The configuration whether your site will open without www or will perform a redirect is not dependent on Sitefinity. You can see how to configure this through IIS here.

    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    08 Nov 2010
    Link to this post
    Hi Radoslav,

    Im not sure thre solution you point to would work because ti wouldn't respond with a 301 status - which is actually the entire reason for doing it in the first place (outside of aesthetic reasons).

    I therefore went for this solution in my Glbal.asax file.

    protected void Application_BeginRequest (object sender, EventArgs e)
    {
       if (!Request.Url.Host.StartsWith ("www") && !Request.Url.IsLoopback)
       {
          UriBuilder builder = new UriBuilder (Request.Url);
          builder.Host = "www." + Request.Url.Host;
          Response.StatusCode = 301;
          Response.AddHeader ("Location", builder.ToString ());
          Response.End ();
       }
    }

    Regards,
    higgsy
Register for webinar
3 posts, 0 answered