1.  <?php 
  2.  一妹子问我的  说想了一天也想不出来  根据我的思路给搞了一个 
  3. $myip = $_SERVER["REMOTE_ADDR"]; 
  4. $ipinfo=file_get_contents("http://www.youdao.com/smartresult-xml/search.s?type=ip&q=".$myip); 
  5.  if(strpos($ipinfo,'北京') > 1) { 
  6. header('HTTP/1.1 301 Moved Permanently'); 
  7. header("Location: http://www.hao123.com");//如果用户ip为北京,则跳转页面 
  8. }else
  9. header('HTTP/1.1 301 Moved Permanently'); 
  10. header("Location: http://www.baidu.com"); 
  11.  
  12. ?>