Erik Schwartz

Erik Schwartz
  • home
  • about
  • projects
  • blog
  • vine

Explorer, weirdo, developer of wonderful things.

Stay curious.

Force Ssl Pantheon

16 Dec 2015

Category: blog

To use SSL throughout the Pantheon dev workflow

When using the dev-my-site.pantheon.io domain (or test or live), put this bad boy at the top of your settings. It will redirect HTTP to HTTPS.

/sites/default/settings.php
<?php

// Require HTTPS on pantheon
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) &&
  $_SERVER['HTTPS'] === 'OFF') {
  if (!isset($_SERVER['HTTP_X_SSL']) ||
    (isset($_SERVER['HTTP_X_SSL']) && $_SERVER['HTTP_X_SSL'] != 'ON')) {
    header('HTTP/1.0 301 Moved Permanently');
    header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    exit();
  }
}

...

Also see the related pantheon docs.

  • home
  • about
  • projects
  • blog
  • vine
  • ©Copyright 2019 Erik Schwartz
  • Handcrafted and designed by Smith Schwartz
  • Portrait illustration by Ryan Schiedt
  • rss