Skip to content

Instantly share code, notes, and snippets.

@smith
Created February 10, 2011 23:04
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 smith/821559 to your computer and use it in GitHub Desktop.
Save smith/821559 to your computer and use it in GitHub Desktop.
Redirects the login page for a mapped domain to the non-mapped domain.
function wildcard_admin_redirect($location, $status = 302) {
$url = parse_url($location);
if ($url['scheme'] === 'https' &&
(preg_match("/\/wp-[login|admin|register]/", $url['path']) > 0)) {
$orig = preg_replace("/^https?:\/\//", "", get_original_url($url['host']));
if ($orig && $orig !== $url['host']) {
$location = 'https://'.$orig.$url[path];
}
}
return $location;
}
add_filter('wp_redirect', 'wildcard_admin_redirect');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment