2016-02-18 55 views
0

我有一个问题,我得到一个重定向循环,我已经完全没有改变它开始。我没有编辑一行代码来停止,并且我已经做了大量的调试,并且找不到问题。

每当我在该搜索框中输入一个邮政编码,它只是给了我一个无限的重定向循环。

我的网站是闪闪发光的洗涤。 COM(不能发布在后两个以上的链路,对不起!)

我的index.php文件:http://pastebin.com/8NuUt6Lu

我的search.php http://pastebin.com/cHjhAFwH

我很抱歉,如果这似乎是一个愚蠢的错误,但我是PHP的新手,我甚至没有写这个。我只是这些人的网页设计师,他们希望我能够解决他们一年前为他们写过的东西。

编辑这是我的.htaccess看起来像http://pastebin.com/4YR6SqMh,我不知道它应该看起来像/做什么。

+1

是不是你的错..但程序员编码这些文件的方式是“真的真的好” .. :| –

+0

而不是复制整个页面尝试仅包括产生问题的代码行。 –

+0

'index.php'代码中有行重定向到'/ searchresult/...',所以我猜这可能是'search.php'?我想,你必须找出答案。但是在'search.php'中没有任何东西可以执行任何重定向。所以看起来你只需要进行更多的调试。 – David

回答

0

更换所有有这样的事情,它更易于阅读和更新位置的项目:

if(!empty($state = $_GET["state"])){ 

    // Location data add multiple lines 
    $locations["/placercounty"] = array(
     "ranges" => array(
      array("from" => 90001, "to" => 96162) 
     ) 
     "matches" => array(
      "california", 
      "placer-county", 
      "auburn", 
     ) 
    ); 
    $locations["/northcentralohio"] = array(
     "ranges" => array(
      array("from" => 44312, "to" => 44312) 
     ) 
     "matches" => array(
      "akron", 
     ) 
    ); 

    // No need to touch below this 
    $state = clean($state); 
    $theZip = strtolower($state); 
    $location = false; 
    foreach($locations as $url => $matchData){ 
     if(isset($matchData["matches"])){ 
      if(in_array($theZip, $matchData["matches"])){ 
       $location = $url; 
       break; 
      } 
     } 
     if(isset($matchData["ranges"])){ 
      foreach($matchData["ranges"] as $rangeData){ 
       if(isset($rangeData["from"]) && isset($rangeData["to"])){ 
        if($theZip >= $rangeData["from"] && $theZip <= $rangeData["to"]){ 
         $location = $url; 
         break 2; 
        } 
       } 
      } 
     } 
    } 
    if($location){ 
     header("Location: " . $location); 
     die(); 
    } 
} 
+0

这会破坏它吗? –

+0

另一个问题可能是你的'.htaccess'文件,你在本地测试,它不起作用,但它在网站上? – Bloafer

+0

我已将我的.htaccess附加到我原来的帖子中。我从来没有搞砸这些,所以如果你有任何想法,我会非常感激! –