Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mikael Mørup 297 posts 326 karma points
    Jun 08, 2011 @ 13:57
    Mikael Mørup
    0

    301 redirect problem

    I have a site  (Umbraco 4.0.2.1  on Windows 2008 server) where the client asked me to implement a "hard redirect" or 301 redirect, so all visits to domain.dk is redirected to www.domain.dk.

    After reading other posts around here i added this to my urlrewriting.config file:

    <add name="seoCanonical"
           
    virtualUrl="http://domain.dk/(.*)"
           
    rewriteUrlParameter="ExcludeFromClientQueryString"
           
    destinationUrl="http://www.domain.dk/$1"
           
    redirect="Domain"
           
    redirectMode="Permanent"
           
    ignoreCase="true" />


    But if i type domain.dk in the browsers address bar i'm not sent to www.domain.dk
    Is there something else i should be doing to make it work.

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 08, 2011 @ 14:47
    Michael Latouche
    0

    Hi Mikael,

    This is "normal" behavior since the idea of the urlrewriting is that you get redirected to another page "behind the scenes" so that it is transparent to the end user.

    I think what you have to do is test in your codebehind if the user comes in with the "domain.dk", and in that case do a Response.RedirectPermanent() to the www.domain.dk page.

    Cheers,

    Michael.

  • Mikael Mørup 297 posts 326 karma points
    Jun 08, 2011 @ 14:54
    Mikael Mørup
    0

    Thank for the answer.

    But it would be a little tedious to have code on all the pages checking for "www" and then redirect.

    The reason the client want the redirect is that they want their web trafic analisys software to see all traffic as coming to the www.domain.dk page.

    Would that work as it i setup now even if the user till see domain.dk ?

    The analisys software is using the usual method with some javascript in the mastertemplate

    Thanks

    Mikael

  • Tom Smith 98 posts 172 karma points
    Jun 08, 2011 @ 15:03
    Tom Smith
    1

    Hi Mikael,

    Try changing redirect="Domain" to redirect="Application" ,

    User should see themselves bounced to new domain (i.e. www.domain.dk)

    Firebug net panel will also show you that client is receiving the correct status codes. I.e. 301 for domain.dk and then 200 for www.domain.dk (this is good, as it means that google's index will also see it, and only index the www version of the site)

    Many Thanks,

    Tom

     

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 08, 2011 @ 15:09
    Michael Latouche
    0

    Hi Mikael,

    I have unfortunately no idea if it will be picked up as www.domain.dk, but my feeling is that it will not: the urlrewriting is more an internal tool to tell the engine where to actally go look for the data to display, so I don't think that the client gets any information about this.

    About the redirect, if should not be so tedious if you have one "root" master template from which all other templates inherit, because then you need to implement the redirect only once in the root template. Also, I am not 100% sure about this, but I think you could actually do the check in the global.asax file (in Application_BeginRequest or something like this).

    And once the user has been redirected to www domain, the subsequent links will send it directly to the www.domain.uk page, so the redirect will be performed on the first client request only.

    Cheers,

    Michael.

  • Tom Smith 98 posts 172 karma points
    Jun 08, 2011 @ 15:21
    Tom Smith
    0

    @Michael,

    urlrewriting.config is Umbraco's way of providing an interface to easily configure it's internal http handler. (i.e. equivilent behavior to response.redirect) that is executed as part of the request handling process (so for every page)

    I use it as a rough and ready SEO tool when I need to clear up a load of indexed dead links post site move. The key is that the client does see the 301 as described in my post above. 

    Many Thanks

    Tom

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 08, 2011 @ 15:28
    Michael Latouche
    0

    @Tom

    Thanks for clearing things out :-)

    Cheers,

    Michael.

Please Sign in or register to post replies

Write your reply to:

Draft