Copied to clipboard

Flag this post as spam?

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


  • Paul Blair 466 posts 731 karma points
    Apr 08, 2010 @ 00:13
    Paul Blair
    0

    URL rewriting - how do I do this?

    I am working on a site and we have changed the main URL.

    I want to be able to do some rewriting, along the lines of:

     - oldURL.com/accommodation -> newURL.com/accommodation

    - oldURL.com/contactdetails - newURL.com/contactUs

    - etc. (many more rules)

    - anything else goes to newURL.com

    How I have set this up is:

        <add name="wwwOldDefault"
             virtualUrl="(.*)://www.oldurl.co.nz(.*)"
             rewriteUrlParameter="IncludeQueryStringForRewrite"
             destinationUrl="$1://www.newurl.co.nz"
             ignoreCase="true"
             redirect="Domain"
             redirectMode="Permanent" />
        <add name="wwwOldAccom"
             virtualUrl="(.*)://www.oldurl.co.nz/accommodation/"
             rewriteUrlParameter="IncludeQueryStringForRewrite"
             destinationUrl="$1://www.newurl.co.nz/planning-your-trip/accommodation"
             ignoreCase="true"
             redirect="Domain"
             redirectMode="Permanent" />

    but it doesn't work as intended. Any ideas on how this should be structured?

    Thanks

    Paul

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Apr 08, 2010 @ 00:35
    Aaron Powell
    0

    Depending on how different the old and new URL's are you may find it easier to create your own UrlRewriting provider.

    If it's purely a domain redirect this should surfice:

        <add name="wwwOldDefault"
             
    virtualUrl="(.*)://www.oldurl.co.nz(.*)"
             
    rewriteUrlParameter="IncludeQueryStringForRewrite"
             
    destinationUrl="$1://www.newurl.co.nz$2"
             
    ignoreCase="true"
             
    redirect="Domain"
             
    redirectMode="Permanent" />

    That'll take everything before & after the domain and place it into the new site.

  • Paul Blair 466 posts 731 karma points
    Apr 08, 2010 @ 01:06
    Paul Blair
    0

    Hi Slace,

    That is how I generally do but the $2 section will be completely different in this particular site so this will not work.

    Thanks

    Paul

  • Paul Blair 466 posts 731 karma points
    Apr 08, 2010 @ 03:41
    Paul Blair
    0

    ok, the best way I can seem to implement this is to set the rewriting as:

        <add name="wwwDobson"
             virtualUrl="(.*)://www.old.co.nz(.*)"
             rewriteUrlParameter="IncludeQueryStringForRewrite"
             destinationUrl="$1://www.new.co.nz$2"
             ignoreCase="true"
             redirect="Domain"
             redirectMode="Permanent" />
        <add name="wwwAccom"
             virtualUrl="(.*)://www.new.co.nz/accommodation"
             rewriteUrlParameter="IncludeQueryStringForRewrite"
             destinationUrl="$1://www.new.co.nz/planning-your-trip/accommodation"
             ignoreCase="true"
             redirect="Domain"
             redirectMode="Permanent" />

    and then set up a 404 redirect to the home page to account for the links that arn't expicitly redirected.

  • Siw Ørnhaug 130 posts 109 karma points
    May 10, 2012 @ 10:30
    Siw Ørnhaug
    0

    Hi guys, I have a case that is pretty similar; old url should be rewritten to new url without changes to the rest - BUT this should happen ONLY when old url has certain querystrings. I'm really not good at this url rewriting regex stuff - could you give me advice?

    Both urls are on the same Umbraco installation, the two domains assigned.

    Example:

    This should not be rewritten: http://www.NT.no/forsiden/europa/amsterdam

    This should be rewritten: http//www.NT.no/forsiden/europa/amsterdam?alttemplate=unikdestinasjon

    to: http:www.UT.no/europa/amsterdam?alttemplate=unikdestinasjon

    Thanks for any response!

     

  • Siw Ørnhaug 130 posts 109 karma points
    May 10, 2012 @ 10:30
    Siw Ørnhaug
    0

    Hi guys, I have a case that is pretty similar; old url should be rewritten to new url without changes to the rest - BUT this should happen ONLY when old url has certain querystrings. I'm really not good at this url rewriting regex stuff - could you give me advice?

    Both urls are on the same Umbraco installation, the two domains assigned.

    Example:

    This should not be rewritten: http://www.NT.no/forsiden/europa/amsterdam

    This should be rewritten: http//www.NT.no/forsiden/europa/amsterdam?alttemplate=unikdestinasjon
    to: http:www.UT.no/europa/amsterdam?alttemplate=unikdestinasjon
     

    Thanks for any response!

     

Please Sign in or register to post replies

Write your reply to:

Draft