If you ever need to redirect a WordPress powered website, but don’t have the ability to control the Nginx config, or have access to a .htaccess file, then you will need to perform the redirect via PHP.

Below is a short piece of code which you can either add to your themes functions.php file or as an mu plugin, which allows you to redirect an entire website to another URL whilst keeping the file structure in tact (ie: the links should still work so long as the permalinks are mapped correctly between the two sites).


 * Redirect all pages on one website to another website.
 * Note: Change 'https://geek.hellyer.kiwi' to the home URL of the new site
function ryans_redirect_site() {

	// Bail out if in admin (there's no point in redirecting admin pages)
	if (
		in_array( $_SERVER['PHP_SELF'], array( '/wp-login.php', '/wp-register.php', '/wp-signup.php' ) )
	) {

	wp_redirect( 'https://geek.hellyer.kiwi' . $_SERVER['REQUEST_URI'], 301 );
add_action( 'init', 'ryans_redirect_site' );