Jump to content

variable for domain name?


pers0n
 Share

Recommended Posts

This is correct, $page->httpUrl is what you are looking for, and it will include the port as well. It will also account for https if the page in question is configured to use https from its template settings.

The equivalent of $config->urls->root that you are looking for then would be:

$pages->get('/')->httpUrl; 

Just note that it has to be accessed at it's URL in order for it to know it. So if you are working with the command line API, it's not going to know it...

  • Like 2
Link to comment
Share on other sites

  • 3 years later...

Old topic but maybe can be useful.

What about adding a global variable? Like this:

$port = ($_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443) ? '' : ':' . $_SERVER['SERVER_PORT'];
$protocol = ($_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
if(!$config->siteURL) $config->siteURL = $protocol . $_SERVER['SERVER_NAME'] . $port . '/';
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...