I'm having a strange issue (possible bug?) with the following (simplified) code
{if segment_1 == ""}
//Do Stuff//
{if:else}
{exp:channel:entries limit="1" status="Open" url_title="{segment_1}" dynamic="no" parse="inward"}
{!-- If no results then paramater must be a category for product listing --}
{if no_results}
{exp:gwcode_categories cat_url_title="{segment_1}" parse="inward"}
//Do Stuff//
{if no_results}
{redirect="404"}
{/if}
{/exp:gwcode_categories}
{/if}
///Do Stuff///
{/exp:channel:entries}
{/if}
The problem is with the 404 redirect. If I set 404 page to none in the backend it correctly redirects to a default page saying: "Status: 404 Page Not Found"
However when I change the 404 setting in the backend to show a custom template, it redirects to the 404 page, regardless of whether a category is found by gwcategories or not, ie no results always ends up being true, or is not correctly parsed.
I've tried a number of permutations of the no results conditional, eg: using
{if {results_total} != 1}{redirect="404"}{/if},
which doesn't work either. Even though testing the output of {results_total} outputs 1, it still redirects.
Anyone got any ideas?