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.

Help creating working 404 template

January 20, 2011 9:55am

Subscribe [3]
  • #1 / Jan 20, 2011 9:55am

    carvingCode

    380 posts

    This question may be related to a resolved thread.

    Hi -

    I’m not having success creating a working 404 page.  EE (2.1.3) always displays the last entry I added using Pages module’s URL structure.

    Example:

    http://domain.com/index.php?/bad_uri

    Whatever the ‘bad_uri’ is, EE always displays the last entry.

    * I do have a 404 template and it is selected in Template Global Prefs.
    * I am using .htaccess URL rewrites to remove ‘index.php’ and the template name.

    Any suggestions?  I will be bringing this website live Feb 1.  It’s a upgrade to an existing site and URL structure (but not domain) has changed, so I’d like to build in 404 processing to handle this.

    Thanks,

    Randy

  • #2 / Jan 20, 2011 4:23pm

    Ingmar

    29245 posts

    Try using strict urls for starters.

  • #3 / Jan 20, 2011 4:51pm

    carvingCode

    380 posts

    Try using strict urls for starters.

    I tried this earlier, but it gave the same results with or without.

  • #4 / Jan 21, 2011 9:29am

    Ingmar

    29245 posts

    It should do exactly what you are looking for: “Enabling Strict URLs requires that the first URL segment be a valid Template Group”. Can you please try without .htaccess, too?

  • #5 / Jan 21, 2011 10:09am

    carvingCode

    380 posts

    No way to use a 404 page in EE without showing template groups?

  • #6 / Jan 21, 2011 5:15pm

    Sue Crocker

    26054 posts

    That’s what the 404 page functionality is about.

    From the docs:

    It is important to note that there are limitations when it comes to what will trigger this “404” type Template to display. ExpressionEngine will only display the 404 Template if the requested Template Group in the URL does not exist.

    Due to the dynamic nature of EE’s URL structure, there is no guarantee about exactly what any particular URL segment represents beyond the first segment. Thus, the error can only be triggered by a Template Group name that doesn’t exist.

  • #7 / Jan 24, 2011 9:33am

    carvingCode

    380 posts

    If I use a test URL on the new website which 1) does not include the ‘index.php’ and 2) does not include any valid template group, the 404 page is correctly displayed.  On the other hand, if I use a test URL which includes the ‘index.php’, a valid template group (some are the same between the two sites), but a segment 2 that is not valid on the new website (individual page uris have changed in the new website), the 404 page is not displayed.  Instead, what appears to be the last entry using a {page_uri} is displayed.

    It seems, if I understand, that I need to be able to trap for ‘segment_2’ in order to display the 404 page for those URLs from the old website that have the same template group.  Can I do this?  Otherwise, it seems I will need to change the name of the template groups within the new website structure.

    Thanks.

  • #8 / Jan 24, 2011 9:48am

    carvingCode

    380 posts

    I think I might have solved my problem by simply renaming one of the template groups on the new website.

    Sometimes, it’s the simplest solutions that elude…

    Thanks.

  • #9 / Jan 24, 2011 3:10pm

    Ingmar

    29245 posts

    Excellent 😊 please do not hesitate to post again in case there’s anything else.

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

ExpressionEngine News!

#eecms, #events, #releases