2013-10-07 2 views
0

"example.com/123"과 같은 특정 추천 URL에서만 내 사이트로 트래픽을 허용하고 싶습니다. 특정 트래픽이 지연된 후 동일한 추천 URL (예 : 1 ~ 2 분)이지나도록 트래픽의 나머지 부분을 리디렉션하고 싶습니다. 나는 example.com/123에서 오는 트래픽 을 더 이상 참조하지 않기를 바란다. 리퍼러에 따라 리디렉션 및/또는 지연 방법은 무엇입니까?

나는 이런 식으로 뭔가를 사용하여 생각하지만 내 요구 사항을 충족하기 위해 편집하는 방법에 단서가있다 :

<?php 
$referrer = $_SERVER['HTTP_REFERER']; 
if (preg_match("/site1.com/",$referrer)) { 
     header('Location: http://www.customercare.com/page-site1.html'); 
} elseif (preg_match("/site2.com/",$referrer)) { 
     header('Location: http://www.customercare.com/page-site2.html'); 
} else { 
     header('Location: http://www.customercare.com/home-page.html'); 
}; 
?> 

답변

0

당신은 페이지의 헤더에 영향을 미치는 당신의 PHP 스크립트에서 뭔가를 할 필요가 없습니다 것입니다이고 실제 서버 응답의 헤더는 아닙니다. 리퍼러 http://example.com/123에서하지

<!-- this is the header of your page --> 
<head> 
    <title>Your Title</title> 
    <?php 
    $referrer = $_SERVER['HTTP_REFERER']; 

    // if referer isn't from example.com/123 we setup a redirect 
    if (!strstr($referrer, '://example.com/123')) 
     print ('<META HTTP-EQUIV=Refresh CONTENT="60; URL=http://example.com/123">\n'); 

    ?> 
    <!-- maybe some other stuff --> 
</head> 

그렇다면,이 라인이 삽입됩니다

그래서 페이지의 헤더를 생성하는 스크립트의 부분에,이 같은 뭔가가 필요 헤더로 : 브라우저에 지시

<META HTTP-EQUIV=Refresh CONTENT="60; URL=http://example.com/123"> 

60 초 후 (이 경우 http://example.com/123에) URL로 리디렉션합니다.