Copied to clipboard

Flag this post as spam?

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


  • Patrik Wanche 11 posts 51 karma points
    Sep 04, 2018 @ 16:59
    Patrik Wanche
    0

    I'm having problem with redirecting to a new domain. What I want to achieve is redirecting (301) all http://www.olddomain.com to https://www.newdomain.com (also http://olddomain.com to https://newdomain.com). Requests for all pages on old domain should all go to startpage on new, so http://olddomain.com/somepage should redirect to https://newdomain.com. Old domain is Umbraco 7.3.4 webforms and the new is Umbraco 7.10.4 MVC.

    In UrlRewriting.config on the old domain site I have configured:

    <add name="myredirect"
                virtualUrl="http://(.*)olddomain.com/(.*)"
                rewriteUrlParameter="ExcludeFromClientQueryString"
                destinationUrl="https://newdomain.com/"
                redirect="Domain"
                redirectMode="Permanent"
                ignoreCase="true" />
    

    What happens if I browse to www.olddomain.com is a YSOD after I have been redirect to the new domain site:

        [NullReferenceException: There is no current PublishedContentRequest, it must be initialized before the RenderRouteHandler executes]
       Umbraco.Web.Mvc.RenderRouteHandler.GetHttpHandler(RequestContext requestContext) +208
       System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +9966527
       System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141
       System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +71
    

    How should I configure this correctly?

  • Harrison 42 posts 254 karma points
    Sep 05, 2018 @ 16:29
    Harrison
    0

    UrlRewriting has slightly different context to IIS Rewrites. Try changing your virtualUrl to "^~/$" to capture everything and redirect to the new site.

  • Patrik Wanche 11 posts 51 karma points
    Sep 05, 2018 @ 17:07
    Patrik Wanche
    0

    Thank you for answering. I have tried your suggestion and unfortunately the result is the same. It seems that I am transferred to the new site and the error occurs there, in my browser the url changes to: https://newsite.com/umbraco/RenderMvc

  • Patrik Wanche 11 posts 51 karma points
    Sep 05, 2018 @ 17:23
    Patrik Wanche
    100

    Just found out that it was Chrome fooling me. An old configuration of the redirect was cached. After resetting this (F12, preserve log, navigate to olddomain.com) it all worked - with my original config.

Please Sign in or register to post replies

Write your reply to:

Draft