Skip to content

Instantly share code, notes, and snippets.

@aydinjavadly
Created October 30, 2021 20:57
Show Gist options
  • Save aydinjavadly/ca8f3fb72aa2de881fd753d52e280f32 to your computer and use it in GitHub Desktop.
Save aydinjavadly/ca8f3fb72aa2de881fd753d52e280f32 to your computer and use it in GitHub Desktop.
WordPress - Setup SSL. Prefer SSL usage for admin area.
<?php
/**
* File: wp-config.php
*
* 1. Prefer SSL usage for admin area
* 2. Check for https existence
*
*/
/** wp-config.php / Prefer SSL usage for admin area */
define( 'FORCE_SSL_ADMIN', true );
/** wp-config.php / Check for https existence */
// 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