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.

404 Not Displaying When Expected

October 16, 2012 10:41am

Subscribe [1]
  • #1 / Oct 16, 2012 10:41am

    LuCmf

    6 posts

    Hi,
    I’m trying to display 404 whenever the segment_2 is not a valid url_title.
    I’ve enabled strict URLs in the control panel.

    My template code looks something like this:

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

    The thing is the no_results conditional isn’t working. It shows nothing…
    I tried with text instead of the redirect and it doesn’t show either.
    Any suggestions?

    Thanks,
    Lu

  • #2 / Oct 16, 2012 5:56pm

    Robin Sowell

    13255 posts

    Is it possible to link to an example page?  And to make sure you’re viewing the template you think you are- might make a test template and put on the top ‘This is a test’- outside of the tag.

    It’s also a good idea to turn template debugging on - in Admin- System Prefs- Output and Debug.  Let’s see if that gets us a little more info when you visit the test page.  Note- without a url_title or entry_id in the url, that should redirect you.  Make sure you do have a 404 template selected.

  • #3 / Oct 17, 2012 7:31am

    LuCmf

    6 posts

    I tried that part of the code in a blank template and it worked fine.
    So I decided to make a new template with the single entry code and embed it in the huge template it was in.

    This way it worked perfectly.

    Thanks for your help!

  • #4 / Oct 17, 2012 4:44pm

    Robin Sowell

    13255 posts

    Aha!  Yep- sounds like something was conflicting.  Embeds are parsed independently, so moving it out eliminated whatever weirdness was happening.  Glad you got it squared away- those can be a bear!

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

ExpressionEngine News!

#eecms, #events, #releases