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.

Showing a 404 for an invalid *category*

August 19, 2008 5:55pm

Subscribe [2]
  • #1 / Aug 19, 2008 5:55pm

    Howdy folks,

    Does anyone know how to display a 404 page (or error page) for an invalid category URL?

    I know how to do it for an invalid entry url by using

    {exp:weblog:entries weblog="{my_weblog}" require_entry="yes"}

    and

    {if no_results}
    {redirect="404"}
    {/if}

    but can’t figure it out for categories.

    Here is an example of a correct URL (for my site):

    http://www.example.com/go/articles/C4

    Here is an example of an incorrect URL (notice the “C” is not capitalized:

    http://www.example.com/go/articles/c4

    When someone links to the incorrect URL, it winds up showing a ton of article links instead of just the articles in the C4 category.

  • #2 / Aug 19, 2008 6:46pm

    Ingmar

    29245 posts

    “c4” is not valid category trigger URL, so it EE will treat it like any other unrecognized URL segment; so, require_entry should work as normal.

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

ExpressionEngine News!

#eecms, #events, #releases