'Location'标题在PHP中根本不起作用

Aks*_*tal 2 php redirect location header

我正在研究一个PHP代码,并且header('Location: '.$location, TRUE, 200);它没有重定向到$location(这里的值是"https://thepiratebay.se/").我列出了所有标题,请帮忙.

正如您所看到的那样,Location标题存在但未重定向到.为什么?

浏览器测试:Chrome,Firefox,IE,Safari.

标题是(如Chrome所示):

HTTP/1.1 200 OK
Date: Sat, 25 Aug 2012 15:10:54 GMT
Server: Apache/2.4.2 (Win32) PHP/5.4.4
X-Powered-By: PHP/5.4.4
Location: https://thepiratebay.se/
Content-Length: 5935
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Run Code Online (Sandbox Code Playgroud)

Dan*_*l M 5

你的错误是200响应代码.

改变这一行:

header('Location: '.$location, TRUE, 200);
Run Code Online (Sandbox Code Playgroud)

成为

header('Location: '.$location, TRUE, $code);
Run Code Online (Sandbox Code Playgroud)

$code301或302 在哪里(永久移动vs暂时移动).