php 301 redirects actually doing a 302 redirect

不羁的心 提交于 2019-12-04 06:28:49

问题


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


回答1:


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.




回答2:


microsoft released a fix for this: http://www.microsoft.com/downloads/en/results.aspx?freetext=980363&displaylang=en&stype=s_basic




回答3:


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

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



回答4:


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/');


来源:https://stackoverflow.com/questions/1562243/php-301-redirects-actually-doing-a-302-redirect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!