Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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:

...

languagephp
linenumberstrue

...

.

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
languagephp
linenumberstrue
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

...