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.

Can't find solution for 404 error under template group

January 08, 2012 2:03pm

Subscribe [2]
  • #1 / Jan 08, 2012 2:03pm

    pixelbaker

    17 posts

    Hi,

    I have successfully setup 404 page for root errors. For example, mysite.com/test-nonexist will be redirect to my 404 page mysite.com/four04.

    However I can’t get this working for template group. For example, mysite.com/blog/test-nonexist will bring a 500 error for normal visitors/members, and a Database error for super admin. I use the template blog.group/index to serve blog pages such as mysite.com/blog/first-post.

    FYI my current strict_url setting is false.

    The methods I’ve tried:
    1. Strict URL method. http://ellislab.com/forums/viewreply/870343/
    I turned strict URL method on, and add {if segment_2 != ''}{redirect="404"}{/if} on the very top of blog.group/index template.
    The result is, all my normal pages got redirected to correct 404 pages. So that’s not acceptable.
    I just followed that method blindly but I think judging if segment_2 is blank is not applicable to my case as I do have valid segment_2 available. What I need to is to redirect to 404 when there is no valid url_title.

    2. I tried to add {if no_results} {redirect="404"} {/if} within Channel Tags of blog/index template, under strict_url off or on. Not working. Still 500 or database error.

    Could you give a hand?

    Thanks!

  • #2 / Jan 08, 2012 2:11pm

    pixelbaker

    17 posts

    Aha, I got it. {if no_resutls} should work together with require_entry=“yes”.

  • #3 / Jan 09, 2012 8:23pm

    Sean C. Smith

    3818 posts

    Hi pixelbaker,

    Yes typically {if no_results}{redirect="404"}{/if} works well. Has this got it working for you now?

    Sean

  • #4 / Jan 09, 2012 11:26pm

    pixelbaker

    17 posts

    Sean, yes, require_entry=“yes” must be added in my case. That’s the only way it works. 😊

  • #5 / Jan 10, 2012 6:32pm

    Sean C. Smith

    3818 posts

    Pixelbaker,

    Excellent. Feel free to post again when you need some more help.

    Sean

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

ExpressionEngine News!

#eecms, #events, #releases