Get current domain

Tony Evyght picture Tony Evyght · May 23, 2012 · Viewed 352.5k times · Source

I have my site on the server http://www.myserver.uk.com.

On this server I have two domains:

one.com and two.com

I would like to get the current domain using PHP, but if I use $_SERVER['HTTP_HOST'] then it is showing me

 myserver.uk.com

instead of:

one.com or two.com

How can I get the domain, and not the server name?

Answer

onehalf picture onehalf · May 23, 2012

Try using this: $_SERVER['SERVER_NAME']

Or parse

$_SERVER['REQUEST_URI']

apache_request_headers()