Re: Mixed content issue on stylesheet
Posted: Mon May 14, 2018 2:38 pm
We're actually using HTTP_X_FORWARDED_PROTO in the Apache htaccess configuration for WonderCMS (also called "better security mode", which works on Apache only), it's the FRONT END HTTPS that was a total new thing to me.
Can you please give this a spin?
Included HTTP_X_FORWARDED_PROTO check and added multiple strtolower checks, as some servers may return "On" instead of "on", HTTPS instead of https, etc.
New modified fix (based on your fix):
For comparison, your fix:
And the last comparison, the original (currently in use in 2.5.1):
Since the above looks like something that will be included in the next version of WonderCMS, would you mind sharing your first name / last name + website link, so it can be included in the special contributors page (https://wondercms.com/special-contributors) and the release notes (https://wondercms.com/whatsnew)?
Can you please give this a spin?
Included HTTP_X_FORWARDED_PROTO check and added multiple strtolower checks, as some servers may return "On" instead of "on", HTTPS instead of https, etc.
New modified fix (based on your fix):
Code: Select all
return 'http' . ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'] == 'on')) || (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS'] == 'on')) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ((($_SERVER['SERVER_PORT'] == '80') || ($_SERVER['SERVER_PORT'] == '443')) ? '' : ':' . $_SERVER['SERVER_PORT']) . ((dirname($_SERVER['SCRIPT_NAME']) == '/') ? '' : dirname($_SERVER['SCRIPT_NAME'])) . '/' . $location;
Code: Select all
return 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && $_SERVER['HTTP_FRONT_END_HTTPS'] == 'on') ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ((($_SERVER['SERVER_PORT'] == '80') || ($_SERVER['SERVER_PORT'] == '443')) ? '' : ':' . $_SERVER['SERVER_PORT']) . ((dirname($_SERVER['SCRIPT_NAME']) == '/') ? '' : dirname($_SERVER['SCRIPT_NAME'])) . '/' . $location;
Code: Select all
return 'http' . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ((($_SERVER['SERVER_PORT'] == '80') || ($_SERVER['SERVER_PORT'] == '443')) ? '' : ':' . $_SERVER['SERVER_PORT']) . ((dirname($_SERVER['SCRIPT_NAME']) == '/') ? '' : dirname($_SERVER['SCRIPT_NAME'])) . '/' . $location;