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.

Weird 404 not displaying problem

March 07, 2012 12:23pm

Subscribe [3]
  • #1 / Mar 07, 2012 12:23pm

    tigerchick

    34 posts

    Hi there,

    I have a problem with my 404 pages not appearing when expected - but only in one area of my site.

    I have strict urls enabled and a custom 404 page setup and specified as site/404 in the template global preferences.

    In most areas of my site this is all working just fine and as expected.

    Any url that has the first segment of the url set as “farm” : see http://www.eastsidecottages.co.uk/farm/ is not behaving as expected however. Misspelling any segment after segment_1 does not result in a 404 as expected but tries to show the content of the farm template. (Although a little mangled). The same behaviour occurs if I add random segments to the end - the expected behaviour would be to throw a 404.

    There is a blog showing single entries at http://www.eastsidecottages.co.uk/farm/farm_blog/ with an example single entry here:
    http://www.eastsidecottages.co.uk/farm/farm_blog/planting_new_woodlands/

    I have incorporated the following code into the single entry template:

    {exp:channel:entries channel="farm_blog" disable="categories|pagination" member_data="yes" limit="1" require_entry="yes"}
       {if no_results}
                            {redirect="404"}
                            {/if}

    There is another blog in the site that works perfectly with this code (it has a different url segment_1) but this is not working correctly.  I tried replacing the redirect with just some text to see if the conditional is working but it does not work.

    The Structure plugin is being used - and I can’t easily disable to test as the site is live and so much relies on it.

    My understanding of the way the EE urls work is that if EE encounters a url segment 2 that is not a template and strict urls is enabled it should result in a 404.

    Thanks for your help in advance. Michael

     

  • #2 / Mar 07, 2012 1:09pm

    glenndavisgroup

    436 posts

    Hi tigerchick,

    Not sure if this will do it but try the following:

    {exp:channel:entries channel="farm_blog" disable="categories|pagination" member_data="yes" limit="1" require_entry="yes"}
       {if no_results}
    
           {redirect="/site/404"}
    
    or
    
           {redirect="/404"}
    
       {/if}

    Cheers,

    Mike

  • #3 / Mar 07, 2012 6:00pm

    tigerchick

    34 posts

    Hi Mike,
    thanks for the suggestion. I tried but it doesn’t work.  Honestly, I don’t think it has anything to do with the conditional on that single entry page but something else entirely.  The lack of a 404 entends to any incorrect url variation that has “farm” as the first segment - but it works perfectly elsewhere on the site.

    I also tried eliminating the redirect address itself as a problem by simply putting some random tag text in the conditional to display id the conditional was working - but it’s not paying any attention to the conditional for some reason.

    Thanks, Michael

  • #4 / Mar 08, 2012 10:23am

    glenndavisgroup

    436 posts

    What version of EE are you using?

    Do you have strict URL’s enabled in your template preferences?

    Thank you,

    Mike

  • #5 / Mar 08, 2012 11:41am

    tigerchick

    34 posts

    2.4 and yes, I have strict URLs enabled.

  • #6 / Mar 08, 2012 12:54pm

    Shane Eckert

    7174 posts

    Hello Michael,

    I am sorry to hear you are running into this problem.

    Structure really changes the way that ExpressionEngine URL’s works, drastically so. I do not see anything obvious in your code, it looks like it should work.

    Instead of disabling the plugin, you might try posing this same question to Jack and Travis and see if they spot something.

    Does that sound like a plan you can live with?

    Let me know and I hope this gets resolved quickly.

    Cheers,

  • #7 / Mar 09, 2012 11:17am

    tigerchick

    34 posts

    Thanks Shane, I’ll pop them a note and see what they say.

  • #8 / Mar 09, 2012 7:20pm

    Sean C. Smith

    3818 posts

    tigerchick,

    Do keep us posted on your progress with this.

    Sean

  • #9 / Mar 13, 2012 8:12am

    tigerchick

    34 posts

    Hi Sean,
    just to give you a quick update in this. The problem was fixed with Travis’  help. 

    The problem was caused by me having a template group called the same as the 1st segment in the url of this section of the site.  I changed the name of the template group and the problem vanished!

  • #10 / Mar 13, 2012 4:46pm

    Shane Eckert

    7174 posts

    Hello tigerchick,

    That’s great to hear. Thanks for letting us know.

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases