php 301 redirects actually doing a 302 redirect

2019-03-05 15:01发布

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/php-general@lists.php.net/msg198576.html

Server is Windows 2008 FastCGI PHP 5

4条回答
霸刀☆藐视天下
2楼-- · 2019-03-05 15:14

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

header('Location: http://www.example.com/', true, 301);
查看更多
时光不老,我们不散
3楼-- · 2019-03-05 15:38

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.

查看更多
劳资没心,怎么记你
5楼-- · 2019-03-05 15:40

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/');
查看更多
登录 后发表回答