Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php $\u GET请求上的重定向循环_Php - Fatal编程技术网

Php $\u GET请求上的重定向循环

Php $\u GET请求上的重定向循环,php,Php,我有点问题,我得到了一个重定向循环,我完全没有改变它开始。我没有编辑任何一行代码使其停止,并且我已经进行了大量调试,没有发现问题 每当我在搜索框中输入邮政编码时,它只会给我一个无限的重定向循环 我的网站是sparkle wash。com(在一篇文章中不能发布超过两个链接,对不起!) My index.php文件: My search.php 如果这看起来像是一个愚蠢的错误,我很抱歉,但我是PHP新手,我甚至没有写这个。我只是这些人的网页设计师,他们希望我能修复一年前有人为他们写的东西 编辑这是我

我有点问题,我得到了一个重定向循环,我完全没有改变它开始。我没有编辑任何一行代码使其停止,并且我已经进行了大量调试,没有发现问题

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

我的网站是sparkle wash。com(在一篇文章中不能发布超过两个链接,对不起!)

My index.php文件:

My search.php

如果这看起来像是一个愚蠢的错误,我很抱歉,但我是PHP新手,我甚至没有写这个。我只是这些人的网页设计师,他们希望我能修复一年前有人为他们写的东西


编辑这是我的.htaccess的外观,我不知道它应该是什么样子/做什么。

用这样的内容替换所有位置项,这样更易于阅读和更新:

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();
    }
}
if(!empty($state=$\u GET[“state”])){
//位置数据添加多行
$locations[“/placeCounty”]=数组(
“范围”=>数组(
数组(“从”=>90001,“到”=>96162)
)
“匹配”=>数组(
“加利福尼亚”,
“砂矿县”,
“奥本”,
)
);
$locations[“/northcentralohio”]=数组(
“范围”=>数组(
数组(“从”=>44312,“到”=>44312)
)
“匹配”=>数组(
“阿克伦”,
)
);
//下面不用碰
$state=clean($state);
$theZip=strtolower($state);
$location=false;
foreach($url=>$matchData形式的位置){
if(isset($matchData[“matches”])){
if(在数组中($theZip,$matchData[“matches”])){
$location=$url;
打破
}
}
if(isset($matchData[“范围])){
foreach($matchData[“ranges”]作为$rangeData){
if(isset($rangeData[“从”])和&isset($rangeData[“到”])){

如果($theZip>=$rangeData[“from”]&&$theZip不是你的错..但是程序员编写这些文件的方式“非常好”..:|不要复制完整的页面,尝试只包含产生问题的代码行。
index.php
代码中有行重定向到
/searchresult/…
,因此我想这可能会转到
search.php
?我想您必须找到。但是
search.php中没有任何内容
执行任何重定向。因此,您似乎需要对其进行更多调试。请尝试放置
die()
exit()
在index.php中的每个标题分配之后,从索引中移动除一个之外的所有重定向,看看会发生什么。同时检查header.php,看看这里是否有任何其他重定向。正如@David所说,search没有任何重定向,我怀疑您重定向到
searchresult?state=
是否有任何重定向她在标题或函数中重定向这将创建循环。我已经测试了当前代码,它似乎按预期运行。这是不是破坏了它?另一个问题可能是你的
.htaccess
文件,你是否在本地测试,它不工作,但在站点上工作?我已将.htaccess附加到我的原始帖子。我从未如果你有任何想法,我将不胜感激!