That is, when the HTTP_HOST is equal to site1.com or site02.com it redirects to newite.com
I've tried something like this below. but it did not work.
<?php if ($_SERVER['HTTP_HOST'] == 'site1.com, site02.com'): ?>
TESTE
<?php endif; ?>
That is, when the HTTP_HOST is equal to site1.com or site02.com it redirects to newite.com
I've tried something like this below. but it did not work.
<?php if ($_SERVER['HTTP_HOST'] == 'site1.com, site02.com'): ?>
TESTE
<?php endif; ?>
With in_array () looks like this:
<?php
$domains = ['www.site01.com','www.site02.com'];
if ( in_array($_SERVER['SERVER_NAME'], $domains ) ) {
// pode adicionar respostas no header depender do que vc precisa
header('Location: https://www.google.com/');
} else {
// faz outra coisa
} ?>
One more thing, use $_SERVER['SERVER_NAME']
or instead $_SERVER['HTTP_HOST']
is easily manipulated by the client, so depending on your purpose there may be something unexpected.
One way is to do this:
if(in_array($_SERVER['HTTP_HOST'], ['site1.com', 'site2.com'])){ //verifica se o valor do HTTP_HOST é um dos sites passados
header('Location: novosite.com');
die();
}