도메인 체크하여 페이지 넘기는 소간단하게 하고 십습니다.
본문
도메인 체크하여 페이지 넘기는 소간단하게 하고 십습니다.
도메인을 체크하여 "domain/index.html"페이지로 넘길려고 하는데 아래소스로 하면은 넘 복잡한거 같아서 질문올립니다.
더 간단한 방법있스시면 알려세요 감사합니다.
<?php
switch ($_SERVER["HTTP_HOST"])
{
case "aaa.com":
header("location:domain/index.html");
break;
case "www.aaa.com":
header("location:domain/index.html");
break;
case "bbb.com":
header("location:domain/index.html");
break;
case "www.bbb.com":
header("location:domain/index.html");
break;
case "ccc.com":
header("location:domain/index.html");
break;
case "www.ccc.com":
header("location:domain/index.html");
break;
case "ddd.com":
header("location:domain/index.html");
break;
case "www.ddd.com":
header("location:domain/index.html");
break;
case "eee.com":
header("location:domain/index.html");
break;
case "www.eee.com":
header("location:domain/index.html");
break;
case "fff.com":
header("location:domain/index.html");
break;
case "www.fff.com":
header("location:domain/index.html");
break;
}?>
답변 1
아래 처럼 작성하시면 소스가 겁나게 짧아 지겠네요 ㅎㅎㅎ
$domain_array = array("aaa.com"=>"//www.naver.com","www.aaa.com"=>"//daum.net","bbb.com"=>"//sir.co.kr");
$zzz = $domain_array["{$_SERVER['HTTP_HOST']}"];
if (array_key_exists($_SERVER["HTTP_HOST"], $domain_array)) {
header("location:$zzz");
}