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() ?


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://';
    $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.

  • Thanks. I'd thought of using //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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.