PHP 301重定向,不可能?

bra*_*ant 15 php http-status-code-301

我一直在尝试进行适当的301重定向,但未能这样做.无论我尝试什么,它总是302重定向.

返回302:

http_redirect("urlgoeshere", '', false, HTTP_REDIRECT_PERM)
Run Code Online (Sandbox Code Playgroud)

返回302:

header("HTTP/1.1 301 Moved Permanently");
header("Location: urlgoeshere");
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释为什么这些回归302而不是301?服务器操作系统是linux,运行PHP/5.2.14.亲自尝试一下.

我会给你们一个URL尝试.我正在使用YSlow和Googlebot进行测试.

应该是301:http://www.fantasysp.com/player/mlb/Albert_Pujols/1486349

Firebug显示302 Code

Ali*_*xel 31

实际上很简单:

header('Location: ' . $url, true, 301);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


如果您正在使用FastCGI,请尝试执行此操作:

header('Status: 301 Moved Permanently', true);
header('Location: ' . $url); // or header('Location: ' . $url, true, 301);
Run Code Online (Sandbox Code Playgroud)