locked
IIS replaces redirect status header from PHP with 302 Redirect automatically RRS feed

  • Question

  • User-117341026 posted

    Both of the following code...

    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.microsoft.com/");
    ?>
    <?php
    header("Location: http://www.microsoft.com/",true,301);
    ?>

    returns...

    HTTP/1.1 302 Redirect
    Content-Type: text/html; charset=UTF-8
    Location: http://www.microsoft.com/
    Server: Microsoft-IIS/7.5
    X-Powered-By: PHP/5.2.9-2
    Date: Mon, 15 Jun 2009 10:09:41 GMT
    Content-Length: 148

    instead of the expected...

    HTTP/1.1 301 Moved Permanently
    Content-Type: text/html; charset=UTF-8
    Location: http://www.microsoft.com/
    Server: Microsoft-IIS/7.5
    X-Powered-By: PHP/5.2.9-2

    Why does this happen?

    Monday, June 15, 2009 6:14 AM

Answers

  • User-1637866776 posted

    This is a bug in IIS FastCGI module. It will be fixed in Windows 7 RTM. We are also looking into possible ways for making this fix available for IIS 7.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Tuesday, June 16, 2009 1:05 AM

All replies

  • User-1315512054 posted

    Hello,

    Try to make 301 redirect directly with IIS and tell us the result - IIS 301 Redirect .

    Regards

    Monday, June 15, 2009 7:32 AM
  • User-117341026 posted

    301 is returned when the URL Rewrite Module is used.

    Monday, June 15, 2009 8:10 AM
  • User-1637866776 posted

    This is a bug in IIS FastCGI module. It will be fixed in Windows 7 RTM. We are also looking into possible ways for making this fix available for IIS 7.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Tuesday, June 16, 2009 1:05 AM
  • User-117341026 posted

    Thanks! The problem doesn't seemt to affect the FastCGI Modules for IIS 5.1 and IIS 6. (I was not able to reproduce it with IIS 5.1, FastCGI 1.5 and PHP 5.2.9-2 NTS on VM)

    Tuesday, June 16, 2009 2:59 AM
  • User-933285918 posted

    Is there any news on this?

    I am having problems with search engines to not consider permanent redirects.

    Thank you very much.

    Monday, November 30, 2009 3:14 PM
  • User-117341026 posted

    Hi Ruben,

    I think the bug has been fixed. Do you have a link for us to test?

    Monday, November 30, 2009 10:05 PM
  • User977006752 posted

    Hi @all, any update on the fix?

    @peaceable_whale : how do you come to the conclusion, that the bug has been fixed?

    i cannot give a link to test, but i have tried it on our server 2008 with iis7 and updates installed and i cannot get it to work.

    I use iirf 2 to rewrite my urls and php 5.3 nts in fastCGI mode.

    To redirect the old url structure to the new one i use php because of the complexity of the url structures.

    This is the code i use for the redirect:

                $location = 'Location: '.$redirectUrl;            
                header('HTTP/1.1 301 Moved Permanently');
                header($location);

    If i observe it with live http headers plugin for firefox it returns a 302 redirect.

    So far it seems that there hasn't been released a bugfix yet.
    I would be glad to be proven wrong.

    One thing i noticed is that my redirect from trailing slash to non trailing slash url in iirf is not replaced with a 302 redirect, but this doesn't help in any way and it has already been pointed out by ruslany, that the replace with 302 redirect is a bug in the fastCGI module.

    If someone has any update on the matter please post it. I have to release our new site and it is due to the fifth of december...

    Thanks in advance

    Wednesday, December 2, 2009 4:48 AM
  • User-117341026 posted

    You are using IIS 7... not IIS 7.5...

    I think the bug has been fixed in IIS 7.5. However, I am not sure if a patch or hotfox has been released for IIS 7. As a workaround, you may want to perform the redirect using the URL Rewrite Module.

    Wednesday, December 2, 2009 11:25 AM
  • User-933285918 posted

    In my case, I find it very difficult to use URL Rewrite. A php program calculates the new URLs of articles canceled for similar items.

    I also read that this problem would be corrected in version 7.5, but I have not located any update for users of version 7.

    Who should know of this problem so we can see a FastCGI update for version 7?

    Thank you very much.

    Thursday, December 3, 2009 3:43 AM
  • User-1405480850 posted

    Yes, we are working on an update for FastCGI on IIS7. This bug will be included in that update.

    Thanks,

    Don.

    Thursday, December 3, 2009 5:12 AM
  • User977006752 posted

    Thanks for the info.

    When can we expect this update to be released?

    I don't want to get into using the Rewrite Module of the IIS because but if the update won't be released anytime soon I will probably have no other choice.

    Thank you in advance for any further info.

    Saturday, December 5, 2009 9:55 AM
  • User977006752 posted

    Thanks for the info.

    When can we expect this update to be released?

    I don't want to get into using the Rewrite Module of the IIS, but if the update won't be released anytime soon I will probably have no other choice.

    Thank you in advance for any further info.

    Saturday, December 5, 2009 9:56 AM
  • User-1405480850 posted

    I can't tell you exact dates but we are working hard to ensure that this gets released as soon as possible. Expect an update around the month of January though is is just an estimate.

    Thanks,

    Don.

    Saturday, December 5, 2009 3:45 PM
  • User-917487323 posted
    Are there any new informations when this bugfix will be released?
    Tuesday, January 19, 2010 8:56 AM
  • User-1405480850 posted

    Hi,

    Today we announced release of FastCGI 1.5 for IIS5.1/6.0. The next step is now to work on back port of this for IIS7.0 which will be happening soon and should fix this defect. Stay tuned, it should be relatively fast now.

    Thanks,

    Don.

    Tuesday, January 19, 2010 12:59 PM
  • User-358041092 posted

     Any news?

    I'm pretty sure it worked a year ago when I migrated to IIS7, but I just happened to check headers were fine as I'm changing some urls and found the 302 bug. Is it know when this broke or am I imagining it ever working?

    Tuesday, February 2, 2010 10:46 AM
  • User-1405480850 posted

    Hi,

    We are still working on the release plan. I will let you know once we have done the release.

    Thanks,

    Don.

    Tuesday, February 2, 2010 10:57 AM
  • User-952514973 posted

    Ich brauch das Update ganz dringend, kann doch nicht sein das so ein Fehler über ein Jahr lang besteht?!

    Friday, February 12, 2010 2:13 PM
  • User260911815 posted

    If only I had known about this bug before implementing big site changes... Surely there must be a rough release plan?

    Thursday, February 25, 2010 7:56 AM
  • User-1405480850 posted

    Hi,

    The FastCGI backport is available to be downloaded form Microsoft download centre and can be viewed at http://www.microsoft.com/downloads/en/results.aspx?freetext=980363&displaylang=en&stype=s_basic. This should fix the above mentioned header redirect bug. The fix is available for Windows Server 2008 and Windows Vista.

    Thank you all for the patience and let us know in case you are facing any problem.

    Regards,

    Don.

    Tuesday, March 9, 2010 7:51 PM
  • User260911815 posted

    It installed and works great on a Windows 2008 x64 web edition. On server 2 which is a 2008 x64 standard the install just display "Searching for updates..", it's been 1,5 hours now. 

    Thursday, March 11, 2010 2:59 AM
  • User-358041092 posted

     installed and tested on 2008 Server 32bit IIS7, works a treat :)

    Sunday, March 14, 2010 1:59 PM
  • User-1405480850 posted

    Thank you for testing and giving feedback. I would encourage everyone else to try this too.

    Regards,

    Don.

    Monday, March 15, 2010 2:11 AM
  • User145391214 posted

    Just like to say this has solved my headache this morning, I'm glad I wasn't one of the unlucky few who have been waiting since last year. I was able to find this solution the same morning I discovered the problem.

    Hotfix installed, 301's functioning correctly.

    Thanks

    Craig

    Friday, June 11, 2010 5:13 AM
  • User-1251039717 posted

     Don,

     I'm having a similar problem, but with an asp redirect instead of a php redirect.  I've set up a redirect and explicitly set the response status to 301, but IIS sends a 302 status instead.  Will this fix address the problem?

     

    Thanks,

    Phyllis

    Friday, May 27, 2011 2:30 PM
  • User-1672167363 posted

    Hello @ pgardner789,

    I belive that Don stopped updating posts as of August 2010.

    I do not know if still monitors the previous posts at IIS Net Forums.

    So I suggest that create a new post / thread and include your question

    and information for php_errors.log the Version of PHP installed with

    how it was installed.

    Then users in the PHP community and IIS Net Forum will try to answer  and help with the issues.

    Thank you,

    Martin

     

    Friday, May 27, 2011 3:16 PM
  • User-1251039717 posted

     Martin,

    Thanks very much for the info, good to know.  

    My problem is not a php issue, i don't use php, my symptoms are the same, but i use asp, and i was hoping the fix addressed the issue regardless of which code is used for the original redirect. 

    i'll post my question in a different forum.

    Thanks,

    Phyllis

     

    Friday, May 27, 2011 3:26 PM
  • User-1672167363 posted

    Hello,

    In the case of asp problems

    I suggest the Rewrite or Scripting Forums.

    Martin

     

    Friday, May 27, 2011 3:28 PM
  • User-687561544 posted

     That URL is not working. Could you please guide me to correct page?

    Friday, August 19, 2011 8:16 AM
  • User-1672167363 posted

    Hello,

    That URL which ?

    Do you mean the link

    to the FastCGI from IIS Net Download

    here http://www.iis.net/download/fastcgi .

    Martin

     

    Friday, August 19, 2011 8:24 AM
  • User-687561544 posted

    Hi Martin,

    Apologies for not been very clear.

    I would like to install the patch to resolve the redirect issue suggested by don.raman

    "The FastCGI backport is available to be downloaded form Microsoft download centre and can be viewed at http://www.microsoft.com/downloads/en/results.aspx?freetext=980363&displaylang=en&stype=s_basic..."

    Regards,

    Bhavin

    Monday, August 22, 2011 4:17 AM
  • User-1672167363 posted

    Hi Bhavin,

    Many of the past Forum posts with links to Microsoft Download

    Center have gone bad since the changes & redesign.

    General Note: The freetext line 980363 is part of the KB980363 MS KB Article.

    The reference is Microsoft Support Article and KB980363 here http://support.microsoft.com/kb/980363 .

    The RuslanY Blog  has a list for collection of patches http://ruslany.net/2010/03/important-update-for-iis-7-0-fastcgi-module/ 

            that has been updated with links X86 & X64 versions for All the Windows that the patches apply.

    AFAIK the patches are have been offered by Windows Update.

    I suggest you check the Support Numbers KB's in the list.

    The patch may already be installed and problems are elsewhere.

    Martin

     

    Monday, August 22, 2011 5:06 AM
  • User-687561544 posted

     Hello Martin,

    I am hosting my sites on a virtual server with Plesk. As soon as I updated the server it crashed and it took few hours for the engineers to revert back. I came to learn you shouldn't be updating windows directly when you have Plesk control panel installed. All though this is not a Windows issue, I thought it's worth people know about this complication.

    I think only option left for me is to control this through URL Rewrite module (which is difficult as the number of redirects are more than 6000) or Go for a fresh build server. 

    Thanks for you help,

    Bhavin

    Friday, August 26, 2011 3:44 AM
  • User-1672167363 posted

    Hello Bhavin,

    Thanks for the update. Yes, Windows Update and cause issues.

    Since your in a VM you may find this http://forums.iis.net/t/1180873.aspx thread

            for how to use Windows Installer in VM systems.

    Martin

     

    Friday, August 26, 2011 3:51 AM