차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
tech:php_redirect [2018/04/30 08:47] V_Ltech:php_redirect [2019/03/13 10:45] (현재) – [301 redirect] V_L
줄 12: 줄 12:
 </file> </file>
  
-exit()를 넣어줌으로써 다른 헤더가 redirect에 영향을 주는 것을 막을 수 있다.+exit()를 넣어줌으로써  현재 Page에서의 [[PHP]]실행을 중지하여 다른 헤더가 redirect에 영향을 주는 것을 막을 수 있다.
  
 ====301 redirect==== ====301 redirect====
줄 20: 줄 20:
 <file php> <file php>
 <?php <?php
-        header("Location: http://test.com/test.php",TRUE,301); +   header("Location: http://test.com/test.php",TRUE,301); 
-        exit();+   exit();
 ?> ?>
 </file> </file>
  
 +상대경로도 가능 
 +<file php> 
 +if(preg_match("iPhone|Mobile|UP\.Browser|Android|BlackBerry 
 +|Windows CE|Nokia|webOS|Opera Mini|SonyEricsson|opera mobi 
 +|Windows hone|IEMobile|POLARIS",$HTTP_USER_AGENT)) 
 +
 +  header("location:/mobile",TRUE,301);exit; 
 +
 +</file>