Last active
August 29, 2015 14:20
-
-
Save ari-gold/b88c6a4192985dfa3298 to your computer and use it in GitHub Desktop.
This file contains 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
if (defined('PANTHEON_ENVIRONMENT')) { | |
/** | |
* Handle Subdomain Redirects. | |
*/ | |
if ($_SERVER['PANTHEON_ENVIRONMENT'] === 'live') { | |
switch ($_SERVER['HTTP_HOST']) { | |
// Remove WWW. | |
case 'www.patch.com': | |
case 'live-patch-fe.pantheon.io': | |
header('HTTP/1.0 301 Moved Permanently'); | |
header('Location: http://patch.com' . $_SERVER['REQUEST_URI']); | |
exit(); | |
// Map <something>.patch.com to patch.com/<something> and let | |
// custom_router_url_inbound_alter() issue a 301 redirect to the | |
// full path including state term | |
default: | |
$subdomain = str_replace('patch.com', '', $_SERVER[HTTP_HOST]); | |
if (strpos($subdomain, '.')) { | |
$_SERVER[HTTP_HOST] = 'patch.com'; | |
$_GET['q'] = str_replace('.', '', $subdomain) . DIRECTORY_SEPARATOR . $_GET['q']; | |
} | |
break; | |
} | |
} | |
// Remove WWW. | |
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) && | |
$_SERVER['PANTHEON_ENVIRONMENT'] === 'live') { | |
if ($_SERVER['HTTP_HOST'] == 'www.patch.com' || | |
$_SERVER['HTTP_HOST'] == 'live-patch-fe.pantheon.io') { | |
header('HTTP/1.0 301 Moved Permanently'); | |
header('Location: http://patch.com'. $_SERVER['REQUEST_URI']); | |
exit(); | |
} | |
} | |
Ah, that was all intended to be on patch frontend... Line 30 on was removed from the previous version and replaced with the top half
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should line 30 onward be on patch-services, not patch-redirects?