Hi community, hope somebody can help me.
I,m trying to redirect to a 404 page if somebody type a wrong URL path. Lets say: The correct URL is: http://testdomain.com/segment_1/segment_2/segment_3/…
e.g. http://testdomain.com/health/vitamins/vitamin-d or one more subcategory like http://testdomain.com/health/general-informations/toxins/toxi-for-cancer-cells
For health as segment 1 the 404 redirect is standard an works fine. e.g heelth instead health would show the 404 page. But for Segment_2, Segment_3 …. i can,t find any reasonable way. IF I change general-informations (segment_2) into something else, it dosent matter, i,m not redirect to 404. It dosent matter if i use e.g. {no result}, {if segment_2 or 3 != ""} or what ever. I always get a list with entries.
But I like that only the exact URL should match and show the right results all other url entries should show the 404 page.
Thanks for any help
I ran into this problem myself, and am still searching for a good solution. As far as I understand it, there is no way other than laboriously white-listing permitted URLs. This is due to the URL-driven nature of EE.
And if I’m wrong, I sure wish someone with more experience will come in and say so 😊
The closest I could come was heavily customizing the templates in each template group to specifically target the last segment they were expecting, i.e. the index template targets segment_2, all the other templates in the group target segment_3.
Good luck.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.