My primary website on a multisite network was created with the www prefix (like www.example.com).

If I try to access pages without the www prefix (like example.com/page-name/ instead of www.example.com/page-name/, I am redirected to the homepage (www.example.com). I would like to change this so I am redirected simply redirected to the same page URL, only with the www prefix.

Additionally, the 404 error page doesn’t work on the primary site. No matter which non-existant URL I try (such as www.example.com/thisdoesnotexist), I am always redirected to the primary site home page (www.example.com), rather then seeing the theme’s 404 page.

Here is a link to my site where you can test the issue.

2 Answers
2

There is currently a bug in the functionality that handles the NOBLOGREDIRECT constant, which causes 404 errors on the main site to be redirected to the value of the constant. Apparently this is the expected behaviour for sub-directory networks (example.com/subsite), but should not take place on subdomain networks (subsite.example.com).

There is a WordPress Trac ticket (#21573) concerning this bug, but there is no indication on when it might be resolved. Until then, you can resolve this error yourself by removing the maybe_redirect_404 function:

remove_action( 'template_redirect', 'maybe_redirect_404' );

This code should go in a .php file in the wp-content/mu-plugins directory. Remember to include a <?php tag at the beginning of the file.

Leave a Reply

Your email address will not be published. Required fields are marked *