테스트 사이트 - 개발 중인 베타 버전입니다

도메인 체크하여 페이지 넘기는 소간단하게 하고 십습니다. 채택완료

ㅐ늑대ㅐ 10년 전 조회 5,218

도메인 체크하여 페이지 넘기는 소간단하게 하고 십습니다. 

 

도메인을 체크하여 "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개

채택된 답변
+20 포인트
10년 전

아래 처럼 작성하시면 소스가 겁나게 짧아 지겠네요 ㅎㅎㅎ

 

$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개

ㅐ늑대ㅐ
10년 전
감사합니다.
네이비칼라
10년 전
테스트 해 보느라 소스가 뒤죽박죽 된것을 그대로 올렸네요.
$zzz 부분을 if문 맨 위에 위치시키세요 ^^

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인