SITE_URL not correct for https sites

Bug #832650 reported by Kitserve
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pluck CMS
Fix Committed
Low
Unassigned

Bug Description

In /data/inc/variables.all.php, this line is wrong:
define('SITE_URL', 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']));

It should be replaced with something like the following:
$protocol = 'http';
if($_SERVER['HTTPS'] and $_SERVER['HTTPS'] != 'off') $protocol .= 's';
$directory = dirname($_SERVER['PHP_SELF']);
if(substr($directory, -1) == '/') $directory = substr($directory, 0, strlen($directory) - 1);
define('SITE_URL', $protocol.'://'.$_SERVER['HTTP_HOST'].$directory);

This should also fix bug #830504.

Tags: core
Revision history for this message
Kitserve (ubuntu-kitserve) wrote :

Minor correction to the above:
if($_SERVER['HTTPS'] and $_SERVER['HTTPS'] != 'off')
should be
if(isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] and $_SERVER['HTTPS'] != 'off')

Revision history for this message
Sander (sanderth) wrote :

Thanks Kitserve for your code! The bug has been fixed in rev. 393.

Changed in pluck-cms:
importance: Undecided → Low
status: New → Fix Committed
milestone: none → 4.7.1
tags: added: core
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.