Versions Compared

Key

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

...

If you are using Kalabox, you should have some basic conditionals that setup your settings.php to operate on Pantheon and your local Kalabox:

Code Block
languagephp
themeRDark
linenumberstrue
/**
 * Terminatur
 *
 * These local settings were generated by terminatur.
 * You may see them if you use Kalastack, Kalabox, Proviso or other local dev
 * tools.
 *
 */
if (isset($_SERVER['KALABOX']) &&  $_SERVER['KALABOX'] === 'on') {
  // DB Array and some common conf.
  $databases['default']['default'] = array(
    'driver' => 'mysql',
    'database' => 'mysite_kala',
    'username' => 'root',
    'password' => 'password',
    'host' => 'localhost',
    'port' => '3306',
    'prefix' => '',
  );
  
  // Error reporting
  error_reporting(-1);  // Have PHP complain about absolutely everything.
  $conf['error_level'] = 2;  // Show all messages on your screen
  ini_set('display_errors', TRUE);  // These lines give you content on WSOD pages.
  ini_set('display_startup_errors', TRUE);

  // Set some common desirable local vars.
  $conf['file_temporary_path'] = '/tmp';
  $conf['file_public_path'] = 'sites/default/files';
  $conf['file_private_path'] = 'sites/default/files/private';
  $conf['reroute_email_enable'] = 1;

  $conf['cache'] = 0;
  $conf['css_gzip_compression'] = FALSE;
  $conf['js_gzip_compression'] = FALSE;
  $conf['preprocess_css'] = 0;
  $conf['preprocess_js'] = 0;
  $conf['site_name'] = 'mysite Local';
  $conf['cron_last'] = '9999999999';
}

...

If you aren't on Kalabox, you should setup something similar. Make sure you don't overwrite any of the existing Kalabox settings or Pantheon configuration:

Code Block
languagephp
themeRDark
linenumberstrue
if (isset($_SERVER['KALABOX']) &&  $_SERVER['KALABOX'] === 'on') {
 // Kalabox stuff from above would be here.
} else {
 // Your custom local environment db configuration and the sane defaults
 // shown in the Kalabox config above should be here.
}

...

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
themeRDark
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();
    }
  }
}

...

Partial Redirects going to legacy site with a new site (Kettering did this)

Code Block
languagephp
themeRDark
linenumberstrue
// 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.
    }
  }
}

...