Advanced-administration-handbook
Advanced-administration-handbook copied to clipboard
SSL on reverse proxy code example update
Issue Description
The code example currently on this page will throw PHP notices when running WP-CLI commands, potentially in other situations in which wp-config.php
is loaded outside the context of a normal web request, or when the request is missing expected headers.
URL of the Page with the Issue
https://wordpress.org/support/article/administration-over-ssl/
Section of Page with the issue
The Reverse Proxy example
Why is this a problem?
PHP notices are noisy.
Suggested Fix
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
Should become...
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
Personally, I'd also add curly braces, but I would ultimately defer that decision to core's code style guide. Not sure what the policy is without looking.