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.

How Do You Handle Error Documents?

September 19, 2011 4:24pm

Subscribe [2]
  • #1 / Sep 19, 2011 4:24pm

    KMGDEV

    121 posts

    I have to deal with this on nearly every site I build, and I really don’t know the best way to handle it.

    My problem with ExpressionEngine’s standard way of dealing with 404s is that it won’t throw an error if the template group is correct in the URL. So if I have a template group called “News” and someone navigates to http://myurl.com/news/wrong_article_url, it will display the index template of the News group, instead of a 404.

    I’ve tried using the .htaccess file to redirect to a static 404 page, but it doesn’t seem to work:

    ErrorDocument 404 /404.html

    Is there something special I need to be doing? What about 500 errors?

    How do you deal with server errors in ExpressionEngine?

  • #2 / Sep 19, 2011 4:37pm

    John St-Amand

    865 posts

    Jovia web studio did a write-up on 404s in EE that I think might be what you’re looking for.

    http://joviawebstudio.com/blog/guide_to_404_pages_with_expressionengine/

    Hope it helps.

  • #3 / Sep 23, 2011 10:55am

    KMGDEV

    121 posts

    GREAT resource, thanks John.

  • #4 / Oct 07, 2011 12:53pm

    KMGDEV

    121 posts

    So I’ve been trying to implement the 404 behavior from that article, but it doesn’t seem to be working!

    I’ve enabled strict URLs in my template preferences. Here’s the code from my template:

    {exp:channel:entries channel="services" limit="1" require_entry="yes"}
                    
                    {if no_results OR segment_2 != ''}
                    
                     {redirect="site/404"}
                    
                    {if:else}
                    
                     {body}
                    
                    {/if}
                    
    {/exp:channel:entries}

    If I navigate to “/services/boo”, it just displays the empty services template. No redirect.

    I am running the Structure module on this site and have the Zoo Triggers add-on installed. Would that have anything to do with it?

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

ExpressionEngine News!

#eecms, #events, #releases