PHP how to get the base domain/url? February 16, 2023 by Tarik Use SERVER_NAME. echo $_SERVER['SERVER_NAME']; //Outputs www.example.com