Skip to content

Instantly share code, notes, and snippets.

@florianbrinkmann
Last active December 28, 2022 23:30
Show Gist options
  • Save florianbrinkmann/7b06b3554572a7d49c55aeefb0950eca to your computer and use it in GitHub Desktop.
Save florianbrinkmann/7b06b3554572a7d49c55aeefb0950eca to your computer and use it in GitHub Desktop.
/**
* If registration for new network sites is disabled,
* the NOBLOGREDIRECT constant redirects to a specific URL
* if a user tries to access a nonexisting network site.
*/
// add this to wp-config.php and adjust the URL
define( 'NOBLOGREDIRECT', 'https://example.com' );
/**
* add this to mu-plugin to keep normal 404 errors
* working instead of redirecting to the above specified URL
* @source: https://wordpress.org/support/topic/404-page-not-working-after-setting-noblogredirect/#post-4844131
*/
remove_action( 'template_redirect', 'maybe_redirect_404' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment