If my site was using ssl, would JUri::root() return a url containing https?
If it didn't, what could I use to return the https equivalent of JUri::root() ?
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.
Sign up to join this communityIf my site was using ssl, would JUri::root() return a url containing https?
If it didn't, what could I use to return the https equivalent of JUri::root() ?
According to the source code - it should return https
:
// Determine if the request was over SSL (HTTPS).
if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off'))
{
$https = 's://';
}
else
{
$https = '://';
}
JUri::root() returns the Url according to the user access. If the user has accessed Joomla from a https Url, then JUri::root() returns the https root url.
As a side note, to create Urls with no protocol definition, to follow the user access preference, you can create Urls like //www.mydomain.com/blalbla.
//www.mydomain.com/blabla
but because of the way I've set up the testing server on localhost it's simpler for me to use JUri::root
– TryHarder
Jan 5 '15 at 13:23