1
I am facing a problem that is to get the domain name of my website. I tried the code:
define('PROTOCOL', 'http://');
define('DOMAIN', (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));
define('SUB_FOLDER', str_replace('public', '', dirname((isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : ''))));
define('BASE_URL', PROTOCOL . DOMAIN . ((substr(SUB_FOLDER, -1, 1) == '/') ? substr(SUB_FOLDER, 0, strlen(SUB_FOLDER)-1) : SUB_FOLDER));
the problem is that HTTP_HOST returns me the server ip and not the domain: web.meusite.com.br
Note: my site is on cluster servers. it has a total of 10 servers 5 in Brazil and 5 in the United States.