Skip to content

Instantly share code, notes, and snippets.

@wernersmit
Created March 7, 2017 21:09
Show Gist options
  • Save wernersmit/5ba1f2a96d7ee8d8d7094f04539960ed to your computer and use it in GitHub Desktop.
Save wernersmit/5ba1f2a96d7ee8d8d7094f04539960ed to your computer and use it in GitHub Desktop.
Fix WP-Admin redirect loop after enabling SSL / HTTPS.
<?php
/*
* Source: http://wordpress.stackexchange.com/a/220896
* Used behind a varnish / nginx reverse proxy setup.
*/
/** SSL */
define('FORCE_SSL_ADMIN', true);
// in some setups HTTP_X_FORWARDED_PROTO might contain
// a comma-separated list e.g. http,https
// so check for https existence
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment