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']) && ($_SERVER['PANTHEON_ENVIRONMENT'] === 'live') && (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(); } }
Sponsored by SupremePR