1

Under Design > Templates > Global Template Preferences I have Strict URLS set to yes and I've defined the 404 page (It lives at /errors/404).

We're running EE 2.8.1 and PHP 5.3.27

Something like http://site.com/foo displays the 404 template and properly returns a 404 header.

This URL exists and displays content properly http://site.com/groups/studies/i-love-my-church

The problem

http://site.com/groups/studies/foo displays the 404 template, but incorrectly returns a 200 response. (http://cl.ly/image/3E3U1N2X2j1L)

EE Docs state that EE will only evaluate the first two segments unless used in conjunction with the require_entry parameter. Unfortunately, using this doesn't change the header.

The code

groups/_studies-collection:

{exp:channel:entries channel="groups_study" url_title="{segment_3}" require_entry="yes" dynamic="off" status="Featured|Open"}

    Content Here

    {if no_results}
        {redirect="404"}
    {/if}
{/exp:channel:entries}

groups/studies:

{if segment_3}
    {if segment_4}
        {embed="groups/_studies-entry"}
    {if:else}
        {exp:md_detect_page_type url_segment="{segment_3}"}
            {if pagination_page}
                {embed="groups/_studies-list"}
            {if:else}
                {embed="groups/_studies-collection"}
            {/if}
        {/exp:md_detect_page_type}
    {/if}
{if:else}
    {embed="newspring:groups/_studies-list"}
{/if}

Any clarity on this issue would be appreciated!

0

2 Answers 2

1

I don't know if it's also in the bug reports, but there is a note in the changelog for 2.9.1 :

Fixed a bug in the 404 redirect behavior when used inside a no_results tag on an embedded template.

This might be your issue if it works as expected outside of an embed.

1
  • Thanks for the response! I believe this is a similar, but different issue. There was a bug I also ran into on 2.9.0 where a 404 would embed a layout twice. I've tried to implement a similar bug fix, but to no avail. I'll take another look just in case!
    – Jon Horton
    Oct 5, 2014 at 21:11
0

The no results conditional doesn't necessarily mean it's a 404 and the fact you have a template called "404" doesn't mean that EE will assume it requires a 404 header - it's just another template.

The strict URLs setting will mean any URL not picked up natively by templates will get the 404 header assigned to it - your URL on the other hand is being passed through a template.

[Edit - seeing as the native 404 redirect isn't working...]

You need to drop a plugin into your 404 template to correctly, try one of these: http://devot-ee.com/search/results?keywords=404+redirect+header&addon_version_support=ee2

2
  • According to EE docs, the {redirect="404"} is supposed to display the 404 page and send 404 headers. It's important to note that the "404" isn't an actual template, but rather a reserved name that can be used with the {redirect} variable. ellislab.com/expressionengine/user-guide/templates/globals/…
    – Jon Horton
    Oct 5, 2014 at 21:09
  • Doh! Must read question more closely!!! Ho hum, as a work around you could use one of the add-ons I suggested :P Oct 6, 2014 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.