IIS replaces redirect status header from PHP with 302 Redirect automatically [Answered]RSS

34 replies

Last post Aug 26, 2011 03:51 AM by HCamper

  • IIS replaces redirect status header from PHP with 302 Redirect automatically

    Jun 15, 2009 06:14 AM|peaceable_whale|LINK

    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?

    Franklin Tse
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Jun 15, 2009 07:32 AM|HostingASPNet|LINK

    Hello,

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

    Regards

    WindowsHostingASP.NET - My favourite site for Windows and IIS hosting information.
    HowtoASP.NET - Free ASP.NET tutorials and source code.
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Jun 15, 2009 08:10 AM|peaceable_whale|LINK

    301 is returned when the URL Rewrite Module is used.

    Franklin Tse
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Jun 16, 2009 01:05 AM|ruslany|LINK

    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.

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Jun 16, 2009 02:59 AM|peaceable_whale|LINK

    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)

    Franklin Tse
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Nov 30, 2009 03:14 PM|Ruben Marti|LINK

    Is there any news on this?

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

    Thank you very much.

    FastCGI IIS 7 302 301

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Nov 30, 2009 10:05 PM|peaceable_whale|LINK

    Hi Ruben,

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

    Franklin Tse
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Dec 02, 2009 04:48 AM|backpacker86|LINK

    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

    FastCGI 302 301

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Dec 02, 2009 11:25 AM|peaceable_whale|LINK

    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.

    Franklin Tse
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Dec 03, 2009 03:43 AM|Ruben Marti|LINK

    <div>

    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.

    </div>

    FastCGI 301 302

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Dec 03, 2009 05:12 AM|don.raman|LINK

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

    Thanks,

    Don.

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Dec 05, 2009 09:55 AM|backpacker86|LINK

    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.

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Dec 05, 2009 09:56 AM|backpacker86|LINK

    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.

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Dec 05, 2009 03:45 PM|don.raman|LINK

    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.

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Jan 19, 2010 08:56 AM|t.zander|LINK

    Are there any new informations when this bugfix will be released?
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Jan 19, 2010 12:59 PM|don.raman|LINK

    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.

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Feb 02, 2010 10:46 AM|deab|LINK

     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?

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Feb 02, 2010 10:57 AM|don.raman|LINK

    Hi,

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

    Thanks,

    Don.

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Feb 12, 2010 02:13 PM|Bambaataa|LINK

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

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Feb 25, 2010 07:56 AM|Elmway|LINK

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

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Mar 09, 2010 07:51 PM|don.raman|LINK

    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.

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Mar 11, 2010 02:59 AM|Elmway|LINK

    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. 

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Mar 14, 2010 01:59 PM|deab|LINK

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

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Mar 15, 2010 02:11 AM|don.raman|LINK

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

    Regards,

    Don.

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Jun 11, 2010 05:13 AM|craig5320|LINK

    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

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    May 27, 2011 02:30 PM|pgardner789|LINK

     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

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    May 27, 2011 03:16 PM|HCamper|LINK

    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

     

    Windows and Linux work Together IT-Pros
    Community Member Award 2011
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    May 27, 2011 03:26 PM|pgardner789|LINK

     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

     

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    May 27, 2011 03:28 PM|HCamper|LINK

    Hello,

    In the case of asp problems

    I suggest the Rewrite or Scripting Forums.

    Martin

     

    Windows and Linux work Together IT-Pros
    Community Member Award 2011
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Aug 19, 2011 08:16 AM|bndoshi|LINK

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

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Aug 19, 2011 08:24 AM|HCamper|LINK

    Hello,

    That URL which ?

    Do you mean the link

    to the FastCGI from IIS Net Download

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

    Martin

     

    Windows and Linux work Together IT-Pros
    Community Member Award 2011
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Aug 22, 2011 04:17 AM|bndoshi|LINK

    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

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Aug 22, 2011 05:06 AM|HCamper|LINK

    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

     

    Windows and Linux work Together IT-Pros
    Community Member Award 2011
  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Aug 26, 2011 03:44 AM|bndoshi|LINK

     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

  • Re: IIS replaces redirect status header from PHP with 302 Redirect automatically

    Aug 26, 2011 03:51 AM|HCamper|LINK

    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

     

    Windows and Linux work Together IT-Pros
    Community Member Award 2011