2013-05-21 3 views
0
<?php 

$rexgeoip = new RexGeoIp; 
$iso = strtoupper($rexgeoip->getCountryIso()); 


    switch ($iso) { 
     case 'DE': 
       header("Location: http://www.domain.de/en/",TRUE,301); 
      break; 

     case 'AT': 
       header("Location: http://www.domain.de",TRUE,301); 
      break; 

     case 'CH': 
       header("Location: http://www.domain.de",TRUE,301); 
      break; 

     default: 
       header("Location: http://www.domain.de/en/",TRUE,301); 
     break; 
    } 
} 

echo "<!-- your iso is $iso -->"; 

?> 

이것은 해당 도메인 경로로 리디렉션되는 코드입니다. 저는 독일에 있고 리디렉션을 테스트하기 위해 DE 사례를/en으로 변경했습니다. 하지만 DE ISO로 공격 할 때마다 "많은 리디렉션"시간 초과가 발생합니다. 이것은 미국이나 아시아의 웹 프록시를 통해 연결하는 경우에도 발생합니다.헤더가있는 스위치 사례의 리디렉션 루프

의견이나 제안이 있으십니까?

+1

당신은 아마 무한 루프에 빠지는 것 때문에 당신이 호스팅 게시 된이 코드 귀하의/en 페이지 또는 그래서 => 당신은 그것으로 리디렉션 된 다음, 귀하의 지역을 테스트하고 리디렉션하려고 시도 ... –

+0

이 스크립트는 우연히 "http : // www .domain.de/en /'또는'http : // www.domain.de /' – Orangepill

+0

둘 다에, 동일한 헤더가 두 언어 모두에서 호출됩니다. –

답변

0

경로에 de를 추가하고 http://www.domain.de/de/ 또는 http://www.domain.de/en/을 담당하는 스크립트에서 리디렉션하지 않습니다

<?php 

$rexgeoip = new RexGeoIp; 
$iso = strtoupper($rexgeoip->getCountryIso()); 


switch ($iso) { 
    case 'DE': 
      header("Location: http://www.domain.de/en/",TRUE,301); 
      exit; 
     break; 

    case 'AT': 
      header("Location: http://www.domain.de/de/",TRUE,301); 
      exit; 
     break; 

    case 'CH': 
      header("Location: http://www.domain.de/de/",TRUE,301); 
      exit;     
     break; 

    default: 
      header("Location: http://www.domain.de/en/",TRUE,301); 
      exit; 
    break; 
    } 
} 

echo "Script never gets here"; 

?> 
+1

리디렉션 할 페이지에 이미 있다면 이쪽으로 리디렉션하지 마십시오. – Adder