Copied to clipboard

Flag this post as spam?

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


  • Swathi 87 posts 281 karma points
    Oct 30, 2015 @ 11:43
    Swathi
    1

    Alternative URL

    Hi,

    I have a requirement where in my current URL that takes content structure has a 6 level length:

    Example: Http://www.example.com/level2/level3/level4/level5/level6

    Not i need this to remain but i also want

    Http://www.example.com/level6

    to open the same page as earlier. (Both should work) Can one Url have an alternate url?

    Thanks in advance, Swati

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Oct 31, 2015 @ 17:04
    Marc Goodson
    2

    Hi Swathi

    If you add a new property to your document type with alias:

    umbracoUrlAlias

    as a textbox

    then magically you can enter here a comma delimited string of alternative urls

    eg.

    "level6,levels/6"

    would add two new alternative urls for your content:

    /level6

    and

    /levels/6

    see https://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracourlalias/

    regards

    Marc

  • Swathi 87 posts 281 karma points
    Nov 01, 2015 @ 06:15
    Swathi
    0

    Hi Marc,

    Tried it, didnt work..

    Should i remove http:// ? is there any specific pattern?

    The link doesnt open

    Swati

  • Martin 114 posts 313 karma points
    Nov 01, 2015 @ 11:20
    Martin
    0

    Are you sure you didn't use a leading slash or perhaps an unintentional space? And did you "save and publish"?

    For example just add level6 in the text field and hit Save and publish. Then http://www.example.com/level6 should work fine.

    And double check that umbracoUrlAlias is spelled correct with capital U and A.

    Good luck!

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Nov 01, 2015 @ 11:22
    Marc Goodson
    1

    Hi Swathi

    Yes, you should not have 'http' in the umbracoUrlAlias field

    just try having

    level6

    typed into the field.

    For example on my blog, I have an umbracoUrlAlias field:

    enter image description here

    If I enter 'level6' into this field for my 'about me' page then that content is available under that url:

    http://tooorangey.co.uk/level6

    enter image description here

    as well as the existing about-me url

    http://tooorangey.co.uk/about-me/

    I can have multiple urls, by using a comma in between each alias:

    enter image description here

    and now the page is additionally available under

    http://tooorangey.co.uk/levels/6

    notice there isn't a slash at the beginning of levels/6, but I'm able to create a url not just in the root of the site.

  • Swathi 87 posts 281 karma points
    Nov 01, 2015 @ 15:24
    Swathi
    0

    Hi guys,

    It worked! thanks a lot for your help :)

    Swati

  • Swathi 87 posts 281 karma points
    Nov 03, 2015 @ 10:48
    Swathi
    0

    Hi again,

    Can you tell me how to use the url name property too. Just to be sure, it doesnt give any alternate url but changes the correct one right?

    I want to know how the new one must be added in the teststring.. i tried the same way with /level6 but it didnt work.

    Requirement: Example: Http://www.example.com/level2/level3/level4/level5/level6

    Should not change to

    Http://www.example.com/level6

    Only 1 url must be available, the new one

    Swati

  • Martin 114 posts 313 karma points
    Nov 03, 2015 @ 10:58
    Martin
    0

    Just use umbracoUrlName instead of umbracoUrlAlias .

    And yes, it should override the page's default url.

  • Swathi 87 posts 281 karma points
    Nov 03, 2015 @ 11:04
    Swathi
    0

    Hi martin,

    I already did that, but it is changing the url only at level 6

    The url is not shortening..

    Example: Http://www.example.com/level2/level3/level4/level5/level6 if i type in "hello" its changing to

    Http://www.example.com/level2/level3/level4/level5/hello

    But i need it to be

    Http://www.example.com/hello

    swati

  • Martin 114 posts 313 karma points
    Nov 03, 2015 @ 15:28
    Martin
    0

    Perhaps you should look into https://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracointernalredirectid but it need a page to select so perhaps not a best option.

    Yes, umbracoUrlName only works a the same level. But doesn't umbracoUrlAlias do what you need? I mean if you write "hello" in the field for umbracoUrlAlias then Http://www.example.com/hello will work.

    Remember that you have to use lowercase!

  • Swathi 87 posts 281 karma points
    Nov 04, 2015 @ 05:21
    Swathi
    0

    Hi Martin,

    Alias works, but it will still have 2 url's.. since this is an alias bothe the longer one and alias one will work, my requirement to have a single url.. the longer one shortened

    Swati

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Nov 07, 2015 @ 22:49
    Marc Goodson
    1

    Hi Swathi

    Yes the way the Umbraco request pipeline works, a series of 'IContentFinders' are executed in a queue, until a match for the requesting url is found.

    https://our.umbraco.org/documentation/reference/routing/request-pipeline/icontentfinder

    There is an IContentFinder, in this pipeline that will look for matches in the umbracoUrlAlias field; and a separate IContentFinder that looks for matches based on the node name / default Url.

    So when you use umbracoUrlAlias - the content can still be found by it's original Url.

    In your initial question, you wanted both to work :-)

    Is the aim now to avoid duplicate entries in search engine indexes ?

    If so you can use a canonical URL to identify the preferred Url to be indexed by the search engine for the content:

    https://support.google.com/webmasters/answer/139066?hl=en

    The other option would be to create your content node at the level you require in your site, eg create level6 as a node under the homepage, and the single url to it will be http://www.example.com/level6.

    Other than that I'm thinking you could create your own IContentFinder, based on Umbraco's ContentFinderByNiceUrl

    https://github.com/umbraco/Umbraco-CMS/blob/d50e49ad37fd5ca7bad2fd6e8fc994f3408ae70c/src/Umbraco.Web/Routing/ContentFinderByNiceUrl.cs

    that would have a additional check on the 'found node' to see if the umbracoUrlAlias property existed, and had been set: if it has been set then your Custom ContentFinderbyNiceUrl would return false; with the result that your node will only be matched by the IContentFinder that looks on umbracoUrlAlias, - but should work normally for other nodes that do not have umbracoUrlAlias set.

    You would have to remove the default Umbraco ContentFinderbyNiceUrl from the umbraco request pipeline, and replace it with your custom version.

    public class RegisterCustomContentFinder : ApplicationEventHandler
    {
      protected override void ApplicationStarting(…) 
      {
        // Insert my finder before ContentFinderByNiceUrl
        ContentFinderResolver.Current
          .InsertTypeBefore<ContentFinderByNiceUrl, MyCustomContentFinderByNiceUrl>();
    
        // Remove ContentFinderByNiceUrl
        ContentFinderResolver.Current.RemoveType<ContentFinderByNiceUrl>();
      }
    }
    

    It's difficult to tell from your example but If it's a whole MVC application you are trying to have route via Urls in the root of the site, with content defined deeper in the tree, then an alternative approach might be to define a custom route and implement an UmbracoVirtualNodeRouteHandler, more details here:

    http://shazwazza.com/post/custom-mvc-routes-within-the-umbraco-pipeline/

  • Swathi 87 posts 281 karma points
    Nov 09, 2015 @ 05:24
    Swathi
    0

    Hi Marc,

    Yes my requirement is to avoid duplicates on search engine.

    I will try the approach you suggested

    Thanks :)

    swati

Please Sign in or register to post replies

Write your reply to:

Draft