Copied to clipboard

Flag this post as spam?

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


  • Søren Mastrup 122 posts 563 karma points c-trib
    Mar 11, 2015 @ 09:33
    Søren Mastrup
    0

    Redirecting individual URL's

    I am trying to redirect a set of pages but can't see to get it to work properly.

    I am trying to redirect a set of urls:

    http://www.domain.dk/payment -> http://newurl.dk/contact/signup-company
    http://www.domain.dk/payment/signup-user -> http://newurl.dk/contact/signup-user
    http://www.domain.dk/payment/signup-company -> http://newurl.dk/contact/signup-company
    

    This is just some of them, but my problem is that if I redirect /payment it also redirects the sub urls. How do I isolate /payment and redirect this without redirecting the child-urls?

    I have tried this:

    <add name="comeOn" redirectMode="Permanent" redirect="Domain" ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite" virtualUrl="http://www.domain.dk/payment" destinationUrl="http://newurl.dk/contact/pay-now" />
    
    <add name="comeOn123" redirectMode="Permanent" redirect="Domain" ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite" virtualUrl="http://www.domain.dk/payment/signup-user" destinationUrl="http://newurl.dk/contact/signup-user" />
    

    When I try to visit "http://www.domain.dk/payment/signup-user" I get the following redirect: "http://newurl.dk/contact/signup-company/signup-user"

    How do I write the redirect correct, so it doesn't do this?

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Mar 12, 2015 @ 14:13
    Alex Skrypnyk
    0

    Hi Søren,

    Try change order of redirect rules.

    This should be last:

    <add name="comeOn" redirectMode="Permanent" redirect="Domain" ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite" virtualUrl="http://www.domain.dk/payment" destinationUrl="http://newurl.dk/contact/pay-now" />
    

    Thanks

  • Søren Mastrup 122 posts 563 karma points c-trib
    Mar 12, 2015 @ 14:22
    Søren Mastrup
    100

    Didn't really think of that! I'll try that next time - Thanks!
    I ended up doing it hard way, by introducing a new field on my master document type and then placing some Razor in my template.

    @if(!String.IsNullOrEmpty(Model.redirectUrl301)){
        string redirectURL = Model.redirectUrl301;
        Response.Status = "301 Moved Permanently";  
        Response.AddHeader("Location", redirectURL);
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft