Copied to clipboard

Flag this post as spam?

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


  • Damiano 5 posts 85 karma points
    Feb 23, 2018 @ 16:11
    Damiano
    0

    Alternative Template http response

    I found some posts about this, but I'm not sure my scenario is the same.

    My main issue is that nodes in my Umbraco render with the alternative templates url syntax (i.e. http://hostname.com/TemplateAlias) for templates are NOT allowed for the node.

    A practical example: the Home node has got only one Allowed template with alias "home". Another template exists with the alias "location". If I type something like http://hostname.com/location the home page is rendered and the HTTP response code is 200. So from a SEO point of view the page http://hostname.com/location exists and it's a duplication of the home page (which to me it's a double mistake). What I would expect for that specific case would be the 404 page with a 404 HTTP response code. Which is exactly what happens if I type: http://hostname.com/loc4tion (no template exists with the alias loc4tion)

    What am I missing? Am I trying to do something wrong?

    I tried to set to true the "disableAlternativeTemplates" in the umbracoSettings.config which works, ignoring the alternatives allowed templates for that node, rendering it with its default template, but still 200 response with a non-existing URL.

    It's like if I add the alias of an existing template and the end of any URL, there will always be a page responding 200, no matter what is set for that page.

    I already have a custom IContentFinder, but that is not fired when a template alias is found.

    Any thoughts?

    Umbraco version 7.7.8 assembly: 1.0.6582.14881

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Feb 23, 2018 @ 16:28
    Dan Diplo
    100

    Maybe also check out the 404handlers.config file (in /config/). By default it looks like:

    <NotFoundHandlers>
      <notFound assembly="umbraco" type="SearchForAlias" />
      <notFound assembly="umbraco" type="SearchForTemplate" />
      <notFound assembly="umbraco" type="SearchForProfile" />
      <notFound assembly="umbraco" type="handle404" />
    </NotFoundHandlers>
    

    Try removing the SearchForTemplate handler from the list. Can't guarantee it will work, but worth a shot.

  • Damiano 5 posts 85 karma points
    Feb 26, 2018 @ 13:09
    Damiano
    0

    Many thanks Dan, it seems to work as expected.

    Now this URL http://hostname.com/location returns a 404 which is correct as there's no location node, location is only a template.

    Is there any other consequence in switching the SearchForTemplate off? Anything I should take care of myself...

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Feb 26, 2018 @ 13:13
    Dan Diplo
    1

    No, there shouldn't be any consequences that I'm aware of (apart from the obvious fact you won't be able to use alternative templates any more :p).

Please Sign in or register to post replies

Write your reply to:

Draft