301리다이렉트 문의드립니다.

301리다이렉트 문의드립니다.

QA

301리다이렉트 문의드립니다.

답변 2

본문

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();

}

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 36
© SIRSOFT
현재 페이지 제일 처음으로