404 not displaying in dev, 302 redirect instead

404 not displaying, 302 redirect instead: can anyone else confirm this is standard behavior? …Or is there an issue with my particular configuration? I can’t test my 404 page in my local trellis vagrant dev environment OR in production, it’s 302 redirecting to the homepage when I type in a non-existing URL.

Sage 8, Multisite, HSTS.

Update: 404 is showing on subdomains, just not on the main domain…

Cheers!

Any plugins or code that might be interfering with this? Does it still happen on a blank install? Any idea what version of Trellis you’re using?

1 Like

@ben thanks so much for the quick reply!

Upon further digging down the rabbit hole :rabbit: it appears that the issue is related to a known bug with the NOBLOGREDIRECT constant and the maybe_redirect_404 function (stackoverflow) that affects WordPress Multisite, complete with an outstanding Trac ticket (#21573) stretching back 5 years.

Solution? Add:

remove_action('template_redirect', 'maybe_redirect_404');

to a functions.php-include, or a mu-plugin (for better portability).

Sorry to spam the Trellis board; when there are so many moving parts you don’t know where to lay blame and, admittedly, I understand Ansible the least of all :pensive:

2 Likes