도메인 체크하여 페이지 넘기는 소간단하게 하고 십습니다. 채택완료
도메인 체크하여 페이지 넘기는 소간단하게 하고 십습니다.
도메인을 체크하여 "domain/index.html"페이지로 넘길려고 하는데 아래소스로 하면은 넘 복잡한거 같아서 질문올립니다.
더 간단한 방법있스시면 알려세요 감사합니다.
switch ($_SERVER["HTTP_HOST"])
{
case "aaa.com":
header("location:domain/index.html");
break;
case "http://www.aaa.com">www.aaa.com":
header("location:domain/index.html");
break;
case "bbb.com":
header("location:domain/index.html");
break;
case "http://www.bbb.com">www.bbb.com":
header("location:domain/index.html");
break;
case "ccc.com":
header("location:domain/index.html");
break;
case "http://www.ccc.com">www.ccc.com":
header("location:domain/index.html");
break;
case "ddd.com":
header("location:domain/index.html");
break;
case "http://www.ddd.com">www.ddd.com":
header("location:domain/index.html");
break;
case "eee.com":
header("location:domain/index.html");
break;
case "http://www.eee.com">www.eee.com":
header("location:domain/index.html");
break;
case "fff.com":
header("location:domain/index.html");
break;
case "http://www.fff.com">www.fff.com":
header("location:domain/index.html");
break;
}?>
답변 1개
아래 처럼 작성하시면 소스가 겁나게 짧아 지겠네요 ㅎㅎㅎ
$domain_array = array("aaa.com"=>"//http://www.naver.com">www.naver.com","http://www.aaa.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"); }
답변에 대한 댓글 2개
$zzz 부분을 if문 맨 위에 위치시키세요 ^^
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인