Skip to content

Instantly share code, notes, and snippets.

@pietrorea
Last active February 7, 2022 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pietrorea/52465cbf207021cfd7928dbe693cee6c to your computer and use it in GitHub Desktop.
Save pietrorea/52465cbf207021cfd7928dbe693cee6c to your computer and use it in GitHub Desktop.
Wordpress wp-config.php - running behind a reverse proxy that terminates SSL
define( 'WP_HOME', 'https://yoursite.com/blog');
define( 'WP_SITEURL', 'https://yoursite.com/blog');
/**
* This is needed for a reverse proxy setup that terminates SSL and forwards /blog to another host.
* Without it, the Wordpress host doesn't know that it needs to make requests to itself using https.
*/
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}
/* Fixes al wp-admin/login links when running in a reverse proxy */
$_SERVER['REQUEST_URI'] = str_replace("/wp-admin/", "/blog/wp-admin/", $_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = str_replace("/wp-login.php", "/blog/wp-login.php", $_SERVER['REQUEST_URI']);
@pietrorea
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment