Bug #23107 See Comments

404 redirect not working with no_results and closed entries

Version: 3.5.6 Reporter: James Catt

This is an archived bug report. If you are experiencing a similar issue, upgrade to the latest release and if that does not solve the problem, submit a new bug report

I have a template set up like so:

{exp:channel:entries channel="my_channel" url_title="{segment_3}" limit="1" status="open"}

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

// rest of template

{/exp:channel:entries}

The 404 redirect works as expected when segment_3 doesn’t match the url_title for any entry in the system—it displays the 404 template I have selected in the system settings.

It doesn’t work, however, when entering a url for an entry that’s closed. In this case, Apache responds with a 404 response code/HTTP header, but there’s no response body. The result for the user thus varies depending on the browser (Chrome displays a default 404 message, whereas Safari just shows a blank page).

Just for the sake of clarity:

http://www.mysite.com/segment_1/segment_2/random-url-that-doesnt-have-an-entry –> displays 404 template as expected

http://www.mysite.com/segment_1/segment_2/url-for-a-closed-entry –> Apache returns 404 with no body

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

ExpressionEngine News!

#eecms, #events, #releases