Copied to clipboard

Flag this post as spam?

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


  • Barloworld Motor Retail 5 posts 75 karma points
    May 23, 2019 @ 10:38
    Barloworld Motor Retail
    0

    umbraco routing

    Hi

    I have 2 Umbraco pages (each with a different Template and Document Type) Expl.

    Home

    --> Page1

    --> Page2

    Why does the routing allows me to view Page2 under Page1? url like: https://Home/Page1/Page2

    how do i prevent this routing?

    Regards Leroux

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    May 23, 2019 @ 15:30
    Marc Goodson
    1

    Hi Barlo

    There is a convention in Umbraco that a url matches the structure of the pages in the content tree, a request will load the matching page with it's published template.

    There is a hidden feature though, of being able to request a page to be loaded with a different template than it is published with... and this is by adding ?altTemplate=aliasofothertemplatehere to the url...

    eg

    /home/page/?altTemplate=anotherTemplate

    now nobody likes querystrings like this, so the convention over the years became

    /home/page/anotherTemplate.aspx

    but nobody uses aspx extensions any more so this became

    /home/page/anotherTemplate

    your page would be loaded with the 'anotherTemplate'

    so my guess is you have called your template page2

    and this is why

    /home/page1/page2 is returning content

    it's returning page1's content but with the 'page2' template!

    You can turn this convention off in /config/umbracosettings.config

    in the web.routing element: set disableAlterativeTemplates to true

     <web.routing
        trySkipIisCustomErrors="true"
        internalRedirectPreservesTemplate="false" disableAlternativeTemplates="true" validateAlternativeTemplates="false" disableFindContentByIdPath="false"
        umbracoApplicationUrl="">
      </web.routing>
    

    regards

    Marc

  • B. Gunnarsson (Bryns) 25 posts 180 karma points c-trib
    May 23, 2019 @ 17:10
    B. Gunnarsson (Bryns)
    0

    Great info, thanks!

  • Barloworld Motor Retail 5 posts 75 karma points
    May 28, 2019 @ 11:23
    Barloworld Motor Retail
    0

    Thanks Marc

    Worked great, but I don't get a 404 page when requesting /home/page1/page2.

    It resolves to Page1

    Any other page (expl. /home/page/page3) returns a 404.

    Any Ideas?

Please Sign in or register to post replies

Write your reply to:

Draft