...
On most sites that are going live, we'll want to make sure all requests are directed to a single domain for ideal SEO and user experience. We do this with a permanent 301 redirect:
...
language | php |
---|---|
linenumbers | true |
...
.
In this example, we're making sure that the default Pantheon domain AND www.mysite.com are redirected to the non-www domain:
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();
}
}
} |
Full Settings.php
...
Sample
Here is an example portion of a settings.php with environmental magic on Pantheon
...