ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Strange template-parsing when strange URL is entered

October 16, 2012 1:40pm

Subscribe [1]
  • #1 / Oct 16, 2012 1:40pm

    lehrerfreund

    263 posts

    Hi,
    my URL-structure is like:
    domain.com/schule/1s/entrytitle
    or
    domain.com/schule/1s/entrytitle/entrynumber

    If you try this, you will see a normal, correctly rendered page: http://www.lehrerfreund.de/schule/1s/lehrer-gehalt-schweiz/4211

    For some unknown reason Users come from Google with an URL where the last slash is missing, that means: http://www.lehrerfreund.de/schule/1s/lehrer-gehalt-schweiz4211

    This URL generates a malformed page: The content (= the article) contains just an

    {/if}

    and the headline to enter a comment (see attachment).

    Is there any way to fix this? I mean to redirect to 404 in such cases or something similar.
    I already have a 404-redirect in my single-entry-template, but this does not work in this case:

    {exp:channel:entries channel="{my_channel}" ..........
    {if no_results OR segment_5!=""}{redirect="schule/404"}{/if}

    Thanks in advance!

  • #2 / Oct 17, 2012 11:55am

    Dan Decker

    7338 posts

    Hi lehrerfreund,

    I’m sorry for your experience with this!

    Your redirect should work, but I think you need to check for segment_4

    <a href="http://www.lehrerfreund.de/schule/1s/lehrer-gehalt-schweiz/4211">http://www.lehrerfreund.de/schule/1s/lehrer-gehalt-schweiz/4211</a>
                                            (1)     (2)             (3)                 (4)

    If you change your conditional to check segment_4, what are your results?

    {if no_results OR segment_4 == ""}{redirect="schule/404"}{/if}

    Cheers,

  • #3 / Oct 17, 2012 2:21pm

    lehrerfreund

    263 posts

    Hi Dan,
    no, “4211” is segment 5 in my case (counting starts with schule = 1). I use the segment-parameter in some other contexts and there it’s similar.

    So this is not the case; perhaps the problem has to do with this line in the htaccess (but I don’t think so):

    ErrorDocument 404 /schule/404

     

  • #4 / Oct 18, 2012 1:55pm

    Dan Decker

    7338 posts

    Hy lehrerfreund,

    Lets get a look. Be expecting an email from EllisLab!

    Cheers,

  • #5 / Oct 18, 2012 4:11pm

    lehrerfreund

    263 posts

    Thanks Dan,
    replied to it, good luck under the engine hood.

  • #6 / Oct 19, 2012 4:44pm

    Dan Decker

    7338 posts

    Hi Berthold,

    We have your information and will be working with you there. Once we have a solution, we’ll post back here with a follow up.

    Thanks!

  • #7 / Nov 02, 2012 6:26pm

    lehrerfreund

    263 posts

    Uah, this was tricky, but Kevin could fix it (thanks Kevin!).

    Thanks for all the support!
    (my case closed)

  • #8 / Nov 02, 2012 6:45pm

    lehrerfreund

    263 posts

    Perhaps I should mention the solution 😊

    This conditional:

    {if no_results OR segment_5!=""}{redirect="schule/404"}{/if}

    seeems not to work in this specific context. I had to split it up in two simple conditionals:

    {if no_results}{redirect="schule/404"}{/if}
    {if segment_5!=""}{redirect="schule/404"}{/if}

     

  • #9 / Nov 05, 2012 12:20pm

    Kevin Smith

    4784 posts

    Glad I could help figure this one out, lehrerfreund! Have a good one.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases