Copied to clipboard

Flag this post as spam?

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


  • Paul Griffiths 370 posts 1021 karma points
    Feb 24, 2015 @ 20:55
    Paul Griffiths
    0

    Redirect any nodes URL's which dont utilise a template

    Hi all,

    I have the following tree structure in my umbraco back office

    enter image description here

    and for each vehicle manufacturer (mercedes, Ford, Vauxhall) the node does not link to a template so if the user is to type the absolute url into the browser they will hit the following page not found page.

    enter image description here

    The manufacturer nodes are mainly used for placeholders so i would like to create a redirect to the parent node our-vehicles.aspx if the user was to type in the www.mysite.co.uk/our-vehicles/mercedes.aspx.

    I have looked into both umbracoUrlAlias and umbracoUrlName but neither seem to work (unless im doing something wrong?)

    Can anyone suggest what i can do in this situation please?

    Thanks

    Paul

  • Sören Deger 733 posts 2844 karma points c-trib
    Feb 24, 2015 @ 21:02
    Sören Deger
    100

    Hi Paul,

    you can create a new template and set this to default for manufacturer nodes. In this new template you write only a 301 permanent redirect to the parent node, maybe like this:

    @{HttpContext.Current.Response.Clear();HttpContext.Current.Response.Status="301 Moved Permanently";HttpContext.Current.Response.AddHeader("Location", Model.Parent.Url);HttpContext.Current.Response.End();}


    Hope this helps.


    Best,

    Sören

  • Paul Griffiths 370 posts 1021 karma points
    Feb 24, 2015 @ 21:18
    Paul Griffiths
    0

    Hey Soren,

    Thanks for your prompt reply! I have created a new template called vehicle manufacturer and placed the code that you referenced in into it. I have mapped the vehicle manufacture node types to use the template but i am still seeing the error.

    I have tried to create a razor script file and put that in the template and although i see no error it doesnt cause a redirect.

    Ive never done this type of thing before so apologies if i am missing something.

    Just to confirm i am using umbraco 6.2

    Cheers

    Paul

  • Paul Griffiths 370 posts 1021 karma points
    Feb 24, 2015 @ 21:21
    Paul Griffiths
    0

    Ignore that last reply your code fixed it!

    Thats exactly what i needed :)

    Thank you!! You have really helped me out :)

    Thanks

    Paul

Please Sign in or register to post replies

Write your reply to:

Draft