Skip to content

Instantly share code, notes, and snippets.

@mojowen
Last active August 29, 2015 14:19
Show Gist options
  • Save mojowen/e7f3727b1ffbdf480aa4 to your computer and use it in GitHub Desktop.
Save mojowen/e7f3727b1ffbdf480aa4 to your computer and use it in GitHub Desktop.
Redirect WordPress to Subfolder from Non-Base Domain
<?php
// Redirects brooklynkindershule.org to campkinderland.org/shule and respects sub paths
function custom_rewrite_basic() {
if( $_SERVER['SERVER_NAME'] == 'brooklynkindershule.org') {
$location = 'http://campkinderland.org/shule';
if( $_SERVER['REQUEST_URI'] && $_SERVER['REQUEST_URI'] != '/shule' ) $location .= '/'.$_SERVER['REQUEST_URI'];
header( 'Location: '.$location );
}
}
add_action('template_redirect', 'custom_rewrite_basic');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment