How To/HTTP to HTTPS redirect

From Roaring Penguin
Revision as of 15:14, 12 March 2014 by MCoyne (talk | contribs) (Created page with "You can do that by making a file: /var/www/canit/site/config.d/0_redirect.php with the following content; <?php # Redirect HTTP => HTTPS if (!array_key_exists('HTT…")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You can do that by making a file:

  /var/www/canit/site/config.d/0_redirect.php

with the following content;

  <?php
  # Redirect HTTP => HTTPS
  if (!array_key_exists('HTTPS', $_SERVER) || !$_SERVER['HTTPS']) {
     header("Location: https://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']);
     exit();
  }
  ?>

Note: nothing before <? or after ?>