douzhechi2435 2016-02-18 13:02
浏览 112

在$ _GET请求上重定向循环

I have a bit of an issue, I'm getting a redirect loop and I've changed absolutely nothing for it to start. I haven't edited a single line of code to make it stop, and I've done extensive debugging and can't find the issue.

Whenever I put a zip code in that search box, it just gives me an infinite redirect loop.

My site is sparkle wash . com (can't post more than two links in a post, sorry!)

My index.php file: http://pastebin.com/8NuUt6Lu

My search.php http://pastebin.com/cHjhAFwH

I do apologize if it seems like a stupid mistake, but I'm new to PHP and I didn't even write this. I'm just these people's web designer and they expect me to fix what they had someone write for them a year ago.

Edit Here is what my .htaccess looks like http://pastebin.com/4YR6SqMh, I have no idea what it should look like/do.

  • 写回答

1条回答 默认 最新

  • doxzrb8721 2016-02-18 13:33
    关注

    Replace all the location items with something like this, its easier to read and update:

    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();
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器