Created
September 28, 2012 06:15
-
-
Save anointed/3798208 to your computer and use it in GitHub Desktop.
Redirects the login page for a mapped domain to the non-mapped domain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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