I‘ve been looking for a methode to change the text on my website depending on the domain ending. For example:
If my website ends with a .ca I want my text to be: mydomain.ca
. If it ends with fr i want it to be mydomain.fr
.
What I have found is a way to make this possible via HTTP:
if( $_SERVER[ 'HTTP_HOST' ] == 'mydomain.co.uk' ) {
$text = "Welcome to our UK website";
}
However I am not a big fan of this methode since you would have to hardcode it and in my opinion this isn’t best practice. I would be happy for any help which could help to find my answer.
CodePudding user response:
You can explode the domain.
$parts = explode('.', $_SERVER['HTTP_HOST']);
$text = 'Surfix is: ' . end($parts);