301리다이렉트 문의드립니다.
본문
2개의 url을 하나의 url 주소로 뜨게 수정해야되는데
예를들면 업체com, 업체1.com 이 모두 업체.닷컴 url로 수정되게 하려합니다.
2개를 적용했더니 업체1.com은 먹히는데 업체.com은 안먹네요
두개모두 수정을 어케해야되나요
//php301 리다이렉트 방법
if( $_SERVER['HTTP_HOST'] == '업체.com' ){
header('HTTP/1.1 301 Moved Permanently' );
header( 'Location: http://업체.닷컴' );
exit();
}
//php301 리다이렉트 방법
if( $_SERVER['HTTP_HOST'] == '업체1.com' ){
header('HTTP/1.1 301 Moved Permanently' );
header( 'Location: http://업체.닷컴' );
exit();
}
답변 2
같은함수가 두번나오니 나중에것만 먹인거같은데....
//php301 리다이렉트 방법
if( $_SERVER['HTTP_HOST'] == '업체.com' ){
header('HTTP/1.1 301 Moved Permanently' );
header( 'Location: http://업체.닷컴' );
exit();
}else{
//php301 리다이렉트 방법
if( $_SERVER['HTTP_HOST'] == '업체1.com' ){
header('HTTP/1.1 301 Moved Permanently' );
header( 'Location: http://업체.닷컴' );
exit();
}
}
이렇게 뭐아니면 뭐. 로 되게 else로 묶어보시는건...?
if( $_SERVER['HTTP_HOST'] == '업체.com' ){
header('HTTP/1.1 301 Moved Permanently' );
header( 'Location: http://업체.닷컴' );
exit();
} else if( $_SERVER['HTTP_HOST'] == '업체1.com' ) {
header('HTTP/1.1 301 Moved Permanently' );
header( 'Location: http://업체.닷컴' );
exit();
}