Can a domain redirect work for both http and https? Currently hosting a site on Pantheon and I would like to redirect traffic to a single domain. There is already a lot of links inside my site that are using: 

http://example.com/somepage, http://www.example.com/somepage, https://example.com/somepage, https://www.example.com/somepage

Since Pantheon uses nginx I would have to use settings.php to redirect traffic. My Question is would it be possible to direct traffic to a single domain but it can be served in either http or https?

Some sample code:

// Require www.
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) &amp;&amp;
  ($_SERVER['PANTHEON_ENVIRONMENT'] === 'live') &amp;&amp;
  (php_sapi_name() != "cli")) {
  if ($_SERVER['HTTP_HOST'] == 'example.com' ||
      $_SERVER['HTTP_HOST'] == 'https://example.com') {
    header('HTTP/1.0 301 Moved Permanently');
    //or https://www.example.com
    header('Location: http://www.example.com'. $_SERVER['REQUEST_URI']);
    exit();
  }
}
Nginx/settings.php


Try this: $base_url = 'https://'.$_SERVER['SERVER_NAME'];


Apache/.htaccess:


You can simply add the following to your .htaccess. It will redirect all traffic from http://example.com and http://www.example.com to https://example.com. Put that below RewriteEngine on. 

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.example\.com*
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]