php 301 重定向实际上做了 302 重定向

发布于 2024-08-08 12:37:14 字数 367 浏览 3 评论 0原文

我一直在谷歌上搜索这个问题,但似乎没有人有答案。

这篇文章很好地描述了这个问题:

http://www .mail-archive.com/[电子邮件受保护]/msg198576.html

服务器是 Windows 2008 快速CGI PHP 5

I have been googling for this but no one appears to have the answer.

This post describes the problem well:

http://www.mail-archive.com/[email protected]/msg198576.html

Server is Windows 2008
FastCGI
PHP 5

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

早乙女 2024-08-15 12:37:15

看来目前这个问题的唯一答案是在使用 PHP 时不要在 IIS7 上使用 FastCGI(因为 FastCGI 中的一个错误)——这是垃圾,因为它非常快。使用 isapi 可以让 301 重定向正常工作,但速度不够快。

It appears that the only answer to this one at the moment is to not use FastCGI on IIS7 when using PHP (because of a bug in FastCGI) - which is rubbish because it's very quick. Using isapi allows the 301 redirects to work as they should, but it's not as fast.

苍白女子 2024-08-15 12:37:15

我这里没有 PHP 来测试这个,但这不会产生 301 吗?

header('Location: http://www.example.com/', true, 301);

I don't have PHP here to test this, but wouldn't this produce a 301?

header('Location: http://www.example.com/', true, 301);
不喜欢何必死缠烂打 2024-08-15 12:37:15

应该由 R. Bemrose 给出;这是通常的示例代码。我猜你的 PHP 执行环境有些不太对劲。

您可以尝试的另一种方法是传回状态行的 CGI 标准方法:

header('Status: 301 Moved permanently');
header('Location: http://www.example.com/');

It should be as given by R. Bemrose; that's the usual example code. I guess there is something not-quite-right about your PHP execution environment.

Another method you can try is the CGI standard way of passing back a status line:

header('Status: 301 Moved permanently');
header('Location: http://www.example.com/');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文