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
Anyone solved this problem?
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
Anyone solved this problem?
I don't have PHP here to test this, but wouldn't this produce a 301?
header('Location: http://www.example.com/', true, 301);
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/');
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.
microsoft released a fix for this: http://www.microsoft.com/downloads/en/results.aspx?freetext=980363&displaylang=en&stype=s_basic
Although not an answer, I thought it might be worth adding that I have a similar issue of getting a 302 instead of a 301, despite the coded status being set as 301 (using VB.Net). I should add that I'm using a custom "404" page to determine if the page really is not found, or if it is listed in our data table of historical redirects.
Me.Response.Status = "301 Moved Permanently"
Me.Response.AppendHeader("Location", rootPath + NewPage)
The rootPath and NewPage variables are obtained from Request.ServerVariables and a SQL database table respectively. Using the nicely detailed HTML analysis viewer from http://www.rexswain.com/httpview.html
the server sends a sequence of status codes as: 302 (the custom 404+301 page handler), then 301, then 200 (the page redirected to).
I've not found anyone suggesting an alternative code method. The best result seems to be manually configuring each 301 in the IIS management console, but this requires that the original file remains on the server, which ain't great.