在我的 URL 中间添加了 5 个字符

5 characters added in the middle of my URL

我意识到这可能是一个非常晦涩的问题,但它让我发疯,在我网站的页面之间导航时,我在 URL 中插入了 5 个额外的字符。 (例如 http://track.chhs.nsw.edu.au/UXTWP/userAccount.php?)正在添加 UXTWP,我不确定从哪里添加,但它随机破坏了导航。

该站点托管在 goDaddy 上。 它包含 HTML CSS PHP JavaScript 和 mySQL。 一切都运行良好,直到我在 PHP 中添加了一个 "fix" 来阻止潜在的 'hack',它会使用在 URL 中传递的 id 来切换查看的内容。 我不确定这是问题所在,但这是错误开始发生之前的最新更改。

这是 site 我也想将代码放在 phpfiddle 上,但我不确定要添加什么?

if(isset($_GET['a'])){
    if(strpos($userRow['sID'], $_GET['a']) !== false) {
        $_SESSION['student']=$_GET['a'];
        $tempArray = db_select("SELECT *  FROM student WHERE sID ='".$_SESSION['student']."'");
        $studentRow = array_shift($tempArray);
        $_SESSION['impactTool'] =$studentRow['impactAssToolID'];
        $SName = $studentRow['sName'];
        $SDOB = $studentRow['dob'];
        $SFormDate = $studentRow['formDate'];
        $prevInf = $studentRow['prevInfo'];
        $famInf = $studentRow['famInfo'];
        $contInf = $studentRow['contextInfo'];
        $impactIDMsg = "?z=".$_SESSION['impactTool'];
        $btnFlag = true;
        }else{
            header("Location:logout.php");
        }

目的是在用户试图访问不属于他们的学生的详细信息时通过注销将用户转回登录屏幕。

在此先感谢您提供的任何帮助。

不是答案,而是观察:

终于遇到了使用curl查看的bug headers:

curl -I http://track.chhs.nsw.edu.au 

输出:

HTTP/1.1 302 Found
Connection: close
Pragma: no-cache
cache-control: no-cache
Location: /TSXbZ/

不久之后,相同的 curl 调用在没有重定向的情况下生成了所需的页面。所以bug不一致,正如你所说。

如果我在 Php 代码中执行 header 位置重定向。或者我使用 .htaccess 规则来做类似的事情:A return header 读起来像这样:

Server: Apache/2.2.22 (Foo)

缺少 apache 服务器 header(对于您的一些回复)让我怀疑代理或缓存层可能位于您的网络服务器和 Php 代码之前。

阅读您的代码,我看不出任何明显的字符插入原因。

注意以下响应的后续差异 (return headers):

3:21% curl -I http://track.chhs.nsw.edu.au       
HTTP/1.1 302 Found
Connection: close
Pragma: no-cache
cache-control: no-cache
Location: /XRjRZ/

3:23% curl -I http://track.chhs.nsw.edu.au
HTTP/1.1 302 Found
Connection: close
Pragma: no-cache
cache-control: no-cache
Location: /

3:24% curl -I http://track.chhs.nsw.edu.au
HTTP/1.1 302 Found
Connection: close
Pragma: no-cache
cache-control: no-cache
Location: /

3:24% curl -I http://track.chhs.nsw.edu.au/index.php
HTTP/1.1 302 Found
Connection: close
Pragma: no-cache
cache-control: no-cache
Location: /index.php

3:24% curl -I http://track.chhs.nsw.edu.au/index.php
HTTP/1.1 200 OK
Date: Fri, 02 Dec 2016 15:24:56 GMT
Server: Apache/2.4.23
X-Powered-By: PHP/5.4.45
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=60d307bdc288bf1371dc5e0c8c397cdf; path=/
Vary: User-Agent
Content-Type: text/html

你有深奥的 .htaccess 或服务器配置吗?

好的,这次我认为它是固定的!!非常感谢@Progrock 坚持不懈的测试和想法。 修复: 我在站点的根目录中包含了一个空白的 .htaccess 文件。 现在我可以使用现场导航和浏览器导航浏览不同的页面,我不能再创建错误了。

我希望这是一个永久性修复,我最好的猜测是 browser/server 在特定触发器上查找 .htaccess 文件,但在查找服务器通用 .htaccess 文件时找不到它.

希望这 post 对以后遇到类似问题的人有所帮助。