Simmons Consulting, the Website of Toby Simmons

Fixing WordPress 1.5 on Windows 2000 (IIS 5)

13
Feb

EDIT: 2005 May 9 — The official fix is out! Download 1.5.1!

Well, I’ve upgraded to WordPress 1.5 and things seem to be going pretty well. I did have to spend the better part of a day trying to figure out why I couldn’t either log in to my admin page from a computer that hadn’t logged in yet, nor could I log out from a computer that was normally logged in. Turns out there is a problem setting a cookie and sending header redirection (a “location:” header) from the same Php file on a Windows 2000 Server (IIS 5).

But there is a workaround. It takes a few manual edits, but I think it fixes most of the problem. — EDIT: 2005 Mar 13 — Please note that the changes I outlined below have become outdated. I have created a zip file with all the necessary changes as will be implemented in the official release of WP 1.5.1. You can download the zip file from my site.

While the changes below work, they are NOT the accepted method for fixing this problem. Please instead use the files contained in the zip file I am providing above.


Starting with the wp-login.php file, open in a text editor and make the following changes:

Line 185: Change this:

  1.       header("Location: $redirect_to");

to this:

  1.       // Start of IIS fix by Toby
  2.       //header("Location: $redirect_to");
  3.       if (strstr(php_uname(), 'Windows'))
  4.          header("Refresh: 0;url=$redirect_to");
  5.       else
  6.          header("Location: $redirect_to");
  7.       // End of IIS fix by Toby

Line 30: Change this:

  1.    header('Location: wp-login.php');

to this:

  1.    // Start of IIS fix by Toby
  2.    //header('Location: wp-login.php');
  3.    if (strstr(php_uname(), 'Windows'))
  4.       header("Refresh: 0;url=wp-login.php");
  5.    else
  6.       header("Location: wp-login.php");
  7.    // End of IIS fix by Toby

Now, open up the wp-pass.php file and make the following changes:

Line 10: Change this:

  1. header('Location: ' . $_SERVER['HTTP_REFERER']);

to this:

  1. // Start of IIS fix by Toby
  2. //header('Location: ' . $_SERVER['HTTP_REFERER']);
  3. if (strstr(php_uname(), 'Windows'))
  4.    <del dateTime="2005-02-21T23:18:1906:00">header("Refresh: 0;url=$_SERVER['HTTP_REFERER']");</del> // props to nate!
  5.    header("Refresh: 0;url=".$_SERVER['HTTP_REFERER']);
  6. else
  7.    header('Location: ' . $_SERVER['HTTP_REFERER']);
  8. // End of IIS fix by Toby

Then, open up the wp-comments-post.php file and make this change:

Line 55: Change this:

  1. header("Location: $location");

to this:

  1. // Start of IIS fix by Toby
  2. //header("Location: $location");
  3. if (strstr(php_uname(), 'Windows'))
  4.    header("Refresh: 0;url=$location");
  5. else
  6.    header("Location: $location");
  7. // End of IIS fix by Toby

That should do it.

— Edit —

Okay, I found some more changes to make. Open wp-admin/link-manager.php and make the following changes:

Line 269: Change this:

  1.     header('Location: '.$this_file);

to this:

  1.    // Start of IIS fix by Toby
  2.    //header('Location: '.$this_file);
  3.    if (strstr(php_uname(), 'Windows'))
  4.       header("Refresh: 0;url=$this_file");
  5.    else
  6.       header('Location: '.$this_file);
  7.    // End of IIS fix by Toby

Line 245: Change this:

  1.     header('Location: ' . $this_file);

to this:

  1.    // Start of IIS fix by Toby
  2.    //header('Location: ' . $this_file);
  3.    if (strstr(php_uname(), 'Windows'))
  4.       header("Refresh: 0;url=$this_file");
  5.    else
  6.       header('Location: ' . $this_file);
  7.    // End of IIS fix by Toby

Open wp-admin/options.php and make the following changes:

Line 87: Change this:

  1.     header('Location: ' . $goback);

to this:

  1.    // Start of IIS fix by Toby
  2.    //header('Location: ' . $goback);
  3.    if (strstr(php_uname(), 'Windows'))
  4.       header("Refresh: 0;url=$goback");
  5.    else
  6.       header('Location: ' . $goback);
  7.    // End of IIS fix by Toby

Open wp-admin/profile.php, make the following changes:

Line 85: Change this:

  1.    header('Location: profile.php?updated=true');

to this:

  1. // Start of IIS fix by Toby
  2. //header('Location: profile.php?updated=true');
  3. if (strstr(php_uname(), 'Windows'))
  4.    header("Refresh: 0;url=profile.php?updated=true");
  5. else
  6.    header('Location: profile.php?updated=true');
  7. // End of IIS fix by Toby

Whew, that’s it for now.

Comments (81) »

  1. Toby, if you have time, could you also try the workaround I proposed? I’m curious to see if manually setting the “Status” will work around this problem in IIS.

  2. Greg says:

    Just a tiny little note…

    on some line you need to strip out the \

    example

    // Start of IIS fix by Toby
    //header(“Location: $location”);
    if (strstr(php_uname(), ‘Windows’))
    header(“Refresh: 0;url=$location”);
    else
    header(“Location: $location”);
    // End of IIS fix by Toby

    should really be

    // Start of IIS fix by Toby
    //header(“Location: $location”);
    if (strstr(php_uname(), ‘Windows’))
    header(“Refresh: 0;url=$location”);
    else
    header(“Location: $location”);
    // End of IIS fix by Toby

    then it works great…

    Thanks man, a definite lifesaver there…

  3. […] o if you’re like me and using WordPress 1.5 on a Windows IIS server, head on over to Toby Simmons fix for this issue.

    […]

  4. Toby Simmons says:

    Ya, cut and paste kinda got me in a few places. I think they are all correct, now. Thanks!

  5. […] to say and for those it offended I can only apologise profusely. EDIT (17/02/05 11:58am): Toby Simmons has a great fix for login issue if you’re using Windows IIS […]

  6. Toby, I mis-remembered the method for overridding the HTTP status. I’ve posted the correct method on mosquito. If you have time, give the updated method a whirl and report the results.

    Thanks!

  7. […] 7;myfile.php’). For a complete list of locations this needs to be done head over to Toby Simmons site where he has a complete rundown on what pages and lines need to be altered. […]

  8. […] ws 2000 (IIS 5) Thursday February 17th 2005, 10:01 pm Filed under WordPress Hacks Simmons Consulting has a fix for Windows 2000 (IIS 5) users who are having problems logging in […]

  9. amanda says:

    I’m still having a problem with this… Instead of logging in properly, it just sends me to a blank screen. I’ve never used wordpress before, and php is about the same as Greek to me. I have little to no idea what I’m doing wrong here. If you can email me, and help me out with this, (or maybe just send me the properly edited files) I would be eternally grateful

  10. […] ­£åœ¨æƒ³è¦ä¸è¦å†æŠŠé‚£å¼µä¸­æŒ‡åœ–擺上來爛的時候,我找到了這樣東西: Fixing WordPress 1.5 on Windows 2000 (IIS 5) 感謝上帝, 我差點就要因為在班級網 […]

  11. gastonl says:

    Thanks I have fixed the login problem but…
    I am using windows 2003 server and I have also the following problems

    I can not access to the EDIT tab ( http://www.noseasboludo.com/wp-admin/edit.php ) it shows ERROR 404 but the file is there

    On Miscellaneous Options, Destination directory shows C:\Domains\noseasboludo.com\wwwroot/wp-content
    And everytime that I press update adds a new \ to the path example
    C:\Domains\noseasboludo.com\wwwroot/wp-content

    Last but not least when I upload an image and post it I have a broken link, if I see the img src like I gets http://www.noseasboludo.com/ “http://www.noseasboludo.com/images/winter_pics_sec_2005_1.jpg/”

    Any other person with the same problems?

    I tried upgrade from 1.2.2 before, then I just started from the scratch with the same luck

    Any help?

  12. patrick says:

    Thanks for the write-up, this saved me hours of grief.

  13. patrick says:

    Thanks for the write-up, this saved me hours of grief.

  14. […] one PC however. Since then I have upgraded to WordPress 1.5 Strahorn. I also came across this post by Toby Simmons which I have implemented. I am happy to say that Tobys solutions res […]

  15. […] ble with the correct URL. I had to edit all of the refferer link handling, (big thanks to Simmon’s Consulting for that). I will be updating the new site with content and artic […]

  16. nate says:

    I did the fix and everything seems to work fine, except now when i try to access a password protected folder, i get the following error:

    “PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\Inetpub\wwwroot\wordpress\wp-pass.php on line 13”

    Can anyone help with this?
    thanks

  17. Toby Simmons says:

    Amanda,

    I kinda hate to send you versions of the files when Matt is going to rework them officially. If you are really desperate, send me an e-mail to toby(at)simmonsconsulting.com and I’ll send you what I got.

    Cheers,

    Toby

  18. Toby Simmons says:

    Nate,

    I never use password protected pages, so I didn’t check that bit of code. Use this on line 13 instead:

    header("Refresh: 0;url=".$_SERVER['HTTP_REFERER']);

    Cheers,

    Toby

  19. Vince says:

    Followed this link
    http://mosquito.wordpress.org/view.php?id=592

    Fantastic! This fix worked perfectly.

    Thanks to all on the above thread who gave this their attention.

  20. […] IIS this bug prevented me from logging into the admin tool and editing the site. Thanks to Toby Simmons and the folks at WordPress.org support I was able to get back on m […]

  21. […] ned here, I finally turned to the tried and true google search, where I came across this: Fixing WordPress 1.5 on Windows 2000 (IIS 5) – by Toby Simmons. The code chan […]

  22. esyang says:

    good job~~~thank you!!!
    you are excellent~~~

  23. gastonl says:

    I just downloaded the version 1.5 (Which is in reality 1.5.1) and the login problem was fixed.

    Feel free to download the ZIP again from http://www.wordpress.org and everything will be fine.

  24. Toby Simmons says:

    Hmm, I just downloaded the regular ZIP and it still contained the code that doesn’t work on IIS. I checked out the Subversion repository and it, too, does not have the fix in it. Can you tell me where you found a 1.5.1 version?

  25. Jim says:

    Ummm… Well, before you go pointing fingers at IIS, I’ve been experiencing the same problem — recycling back to the login page. The difference is I’m running Apache 2 / PHP 5, I do have to admit I’m running XP as the OS…so I wonder if it’s OS related rather than server related.

  26. […] g IIS as the server. There is a full explanation of how to I went about fixing the problem here.

    Leave a Reply
    […]

  27. Chiarimento su WordPress

    Riguardo a quanto scrivevo qui sul problema che avevo avuto con WordPress, ho ricevuto una mail di Vittorio. Mi segnala che nello specifico si tratta di un bug di IIS (il web server di Microsoft) e che una soluzione è stata trovata:Fixing WordPress 1….

  28. Michael says:

    I had login problems with xampp and Windows when testing 1.5. I switched over to Linux (still using xampp) and the login problems disappeared. Strange.

  29. […] 於是我轉向google大神求救,馬上就找到了網友Toby Simmonsçš„Blog裡有提供解決方案,有需要的人可以參考。 WP 1.5用的感覺上還不錯,內建的styleä […]

  30. Anthony says:

    Thank you for the thorough instructions and explanation about this! I spent hours trying to figure out what was going on and, as it turns out, there were more problems than just IIS playing unfairly. I don’t know if this has happened to others but, before we go blaming IIS for being the only cause of this login-redirect issue, I wanted to point out that Firefox can also cause a similar problem which, if I hadn’t read this post, I’d have thought was the only reason for my headaches. Turns out that my personal preference for only allowning session cookies created by the originating site can send you in a login-loop, as well. Every time I tried to login I’d be sent right back to the login screen except that, unlike the IIS issue, there was a “session timed out” error. Using Internet Explorer didn’t result in the same problem and this is what tipped me off to the fact that I need to make an exception to allow cookies for my WordPress server in Firefox. Hopefully, others will see this (buried) comment and not make the same mistake I did…or, if they do, they won’t waste too much time trying to sort things out!

  31. Alex Aguilar says:

    Thanks Toby. Just when I was starting to loose my patience I decided to google ‘WordPress 1.5 Windows Login’

  32. Ian says:

    Yeah, thanks a lot Toby. I thought I sucked at computers for a while.

  33. Todd says:

    Toby…..

    YOU ROCK MAN!!!!!!

    Thanks so much for posting this IIS fix… Did the trick for me. The thing works perfectly now….

  34. //*Thanks I have fixed the login problem but…
    I am using windows 2003 server and I have also the following problems

    I can not access to the EDIT tab ( http://www.noseasboludo.com/wp-admin/edit.php ) it shows ERROR 404 but the file is there

    On Miscellaneous Options, Destination directory shows C:\Domains\noseasboludo.com\wwwroot/wp-content
    And everytime that I press update adds a new \ to the path example
    C:\Domains\noseasboludo.com\wwwroot/wp-content

    Last but not least when I upload an image and post it I have a broken link, if I see the img src like I gets http://www.noseasboludo.com/ “http://www.noseasboludo.com/images/winter_pics_sec_2005_1.jpg/”

    Any other person with the same problems?

    I tried upgrade from 1.2.2 before, then I just started from the scratch with the same luck

    Any help? *//

    yes,i with the same problems,who can help me~

  35. […] al post test

    note to self

    login workaround correction is here. wil fix later today…… ignore this post of you’re aregular designboxer […]

  36. Mike says:

    Thanks so much for this Toby – it was driving me nuts being restricted to the one browser & machine that the login worked on. This fix worked for me perfectly :)

  37. […] 1.2 ho aggiornato all’1.5 ho eseguito il fix per hosting su windows che ho trovato qui

    This entry was posted

    on Friday, March 11th […]

  38. […] the only one to encounter login issues with WordPress. I came across an article entitled Fixing WordPress 1.5 on Windows 2000 (IIS 5) over at SimmonsConsulging.com whic […]

  39. […] d?

    There is a problem when using Windows based hosting. Here is a solution: https://www.simmonsconsulting.com/wpbeta/?p=160.

    10:59 pm
    Techn […]

  40. […] 2005 WP 1.5 fix for IIS 5 Categories – WordPress Hack LinkyLoo — Mark WP 1.5 fix for IIS 5: Fix for login issues with WordPress 1.5 on IIS 5 servers. I am sure someo […]

  41. […] . Ja em sonava que havia vist a PlanetaWP que algu havia tingut problemes amb el IIS i que proposava tocar no se quants fitxers per arreglar-ho. Per sort, aquest home s&# […]

  42. […] 8217; … Para aquellos que tengan en mente montar 1.5 en Windows, aquí encontré una solución para eso… y parece que funciona bien. Aquellos en Linux o Unix […]

  43. […] the only one to encounter login issues with WordPress. I came across an article entitled Fixing WordPress 1.5 on Windows 2000 (IIS 5) over at SimmonsConsulting.com whic […]

  44. Stephan says:

    Thanks a lot! At last an easy solution for this stupid problem :-)

  45. T1Dude says:

    I am having the same problem as another poster on this page: I copied over all the new files and not I just get blank pages for everything after I login. …even when I manually type in new page names after logging in. Any ideas?

    peace,
    dude

  46. Chuck Wyatt says:

    Yep, just installed WordPress 1.5 on my Win2K IIS box. No workie, the admin login page just cycles. I tried the zip file and did replace those in the install.

    Should I try a different release of WP?

  47. […] It Works!!! I got WP to work, despite IIS5!!! Big plug to Simmons Consulting for getting the future WP 1.5.1 fix put together to resolve this! Time to […]

  48. Amitabh says:

    Hi it works, these guys need to l;earn from u..

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>