...
Code Block | ||||
---|---|---|---|---|
| ||||
if (isset($_SERVER['PANTHEON_ENVIRONMENT'])) { if($_SERVER['PANTHEON_ENVIRONMENT'] === 'live') { // settings for launching Featured Events if($_SERVER['HTTP_HOST'] == 'live-mysite.gotpantheon.com' || $_SERVER['HTTP_HOST'] == 'www.mysite.com'){ header('HTTP/1.0 301 Moved Permanently'); header('Location: http://mysite.com'. $_SERVER['REQUEST_URI']); exit(); } } } |
Partial Redirects going to legacy site with a new site (Kettering did this)
Code Block | ||
---|---|---|
| ||
// REDIRECTS
if (isset($_SERVER['PANTHEON_ENVIRONMENT'])) {
if ($_SERVER['PANTHEON_ENVIRONMENT'] === 'live') {
// Easily Change status code and base url for testing here:
$host = 'headrfootr-kettering.gotpantheon.com';
$http_code = 'HTTP/1.0 303 See Other';
$redirect = FALSE;
// Add URLS to skip this AKA 1-1:
$skip = array(
'/admissions/test',
'/news/trill',
);
// Set this to a var so we don't mess with doing all this fun stuff below.
$uri = $_SERVER['REQUEST_URI'];
// Redirect to legacy site based on set patterns, etc.
if (!in_array($uri, $skip)) {
$old = array(
'admissions',
'news',
'research',
'alumni-donors',
'current-students',
'faculty-staff',
'office-administration',
'ferpa',
'emergency',
'academics',
);
// Time to make the magic happen.
$uri_check = explode('/', $_SERVER['REQUEST_URI']);
// Check for Wildcard Redirect first.
if (isset($uri_check[1]) && in_array($uri_check[1], $old)) {
$redirect = TRUE;
}
// Redirect to specific legacy pages.
elseif (isset($uri_check[1])) {
switch ($uri_check[1]) {
case 'alumni':
$redirect = TRUE;
$uri = '/alumni-donors/get-involved';
break;
case 'directory':
$redirect = TRUE;
$uri = '/faculty-staff/directory';
break;
case 'giving':
$redirect = TRUE;
$uri = '/give';
break;
case '/about/accreditation-and-assessment':
$redirect = TRUE;
$uri = '/about/accreditation-and-assessment';
break;
}
}
}
// If true above, lets have some fun redirects happen!
if ($redirect) {
header($http_code);
header('Location: http://'. $host . $uri);
exit();
}
else {
// NORMAL PANTHEON BASE URL REDIRECT WILL GO HERE.
}
}
} |
Full Settings.php Sample
Here is an example portion of a settings.php with environmental magic on Pantheon
...