Skip to content

Instantly share code, notes, and snippets.

@kovshenin
Created April 13, 2022 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kovshenin/4d90f2057e8d0d91dca2a6ccf7bc9642 to your computer and use it in GitHub Desktop.
Save kovshenin/4d90f2057e8d0d91dca2a6ccf7bc9642 to your computer and use it in GitHub Desktop.
<?php
add_action( 'muplugins_loaded', function() {
if ( defined( 'WP_CLI' ) && WP_CLI ) {
return;
}
if ( empty( $_SERVER['HTTP_HOST'] ) ) {
return;
}
// Redirect to primary domain
if ( strtolower( $_SERVER['HTTP_HOST'] ) !== 'www.primary.org' ) {
wp_redirect( 'https://www.primary.org' . $_SERVER['REQUEST_URI'], 301 );
exit;
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment