0
That is, when HTTP_HOST is equal to site1.com or site02.com it redirects to novosite.com
I tried something like this below. but it didn’t work.
<?php if ($_SERVER['HTTP_HOST'] == 'site1.com, site02.com'): ?>
TESTE
<?php endif; ?>
0
That is, when HTTP_HOST is equal to site1.com or site02.com it redirects to novosite.com
I tried something like this below. but it didn’t work.
<?php if ($_SERVER['HTTP_HOST'] == 'site1.com, site02.com'): ?>
TESTE
<?php endif; ?>
2
With in_array() gets 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 of $_SERVER['HTTP_HOST']
is easily manipulated by the client, so depending on its purpose there may be something unexpected.
0
One way is to do it like 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();
}
Browser other questions tagged php html http
You are not signed in. Login or sign up in order to post.