2

Someone in my studio designed a webpage some years ago, and now the client decided to change the server (he moved to a Linux Apache server running Gen2 SMP, 64 bits, PHP version 5.3.8, Standard MYSQL version 5). It suddenly started to do weird things.

When clicking on a link that requires login, the page redirects you to the login page using header() function in PHP. Curiously, the page shows this:

OK

The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. HTTP/1.1 200 OK Date: Mon, 15 Oct 2012 17:27:32 GMT Server: Apache/2.2.22 (Unix) FrontPage/5.0.2.2635 X-Powered-By: PHP/5.3.8 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Keep-Alive: timeout=5, max=399 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html 232c

Then the page itself, and then, another header:

0 1f4

OK

The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. 0

What's most intriguing is that if you refresh the page or hit enter on the url, it loads correctly. I've been checking the logs, and it only blames of an inexisting favicon. I also checked the .htaccess, everything was correct (RewriteBase was / as intended, and the only stuff there is another rule that moves ^en/ requests to request?lang=en. Has anyone faced something like this?

Edit: IE doesn't trigger these two headers. This is getting wierder.

The solution!: As @adaptr pointed out, it was a matter of PHP and not any server related thing. The last coder (I know it's not polite to blame the predecessor, but this situation has taken me too much time) did this:

/* config.php -> included everywhere as a bootstrap*/
// ... constant/mysql setup

if($notLogged)
{
    $forward = ...;//previous url
    header("Location: ".WWW.LANG."/customer-area/login/index.php?forward=".$forward);
    exit;
}

After looking deeper, something twisted me: exit; would correctly send the headers, or wouldn't? Of course, removing that exit; would keep executing the page (I know it's not correct at all, that's why I didn't try it before). However, if the headers weren't being completely sent, it could cause any kind of problem (I'm not a server guy, I'm not sure about that, sorry mates). After removing that exit; call, the page was being correctly formed, the headers got "closed" (because of the output start) and all the gears started moving again. Thank you all, guys, best bountied 100 points =)

3
  • Why don't you check the access logs? And filter by the user's requests. See what the 3 requests are and if there's a chain of redirects in there.
    – Grumpy
    Oct 18, 2012 at 9:21
  • They aren't requests unless he can show access logs that prove they are. They are responses to (at least) one request.
    – adaptr
    Oct 18, 2012 at 9:23
  • Indeed, the server tries to load two more php files (js.php and css.php), but they are not embedded prior to the reload. Oct 19, 2012 at 10:13

2 Answers 2

1
+100

If the apache logs don't show any errors, that means PHP handled all of this - and also returned the weird responses to the client.

Enable proper PHP logging and investigate what it is doing.

This bit in the response is indicative:

Transfer-Encoding: chunked

That means PHP is sending the response in a (text/html) stream that has no Content-Size defined in the headers.

This may cause any header output (something PHP caches often, i.e. it is generated out-of-order) that slips up even a little bit to cause the client to think a new page is being sent.

That is just one possible reason; proper PHP logging will tell you more.

1
  • Well, you put me back to track. I added a short explanation of what I found when looking deeper at the code. Thank you! (I'd +1 you too, but 13 points are not enough to vote up xD) Oct 19, 2012 at 17:07
0

You need to debug the page code instead of looking at the server for the reason. I can see from what you posted that is was created using FrontPage (really, a professional used that?), so it inevitably contains code that will not work properly on a non-Microsoft platform. Fix the code by removing all the Microsoft specific code and it may run correctly.

2
  • hmmm, I can assure he didn't use FrontPage (here at this company we take seriously that kind of behaviours, the dev side doesn't even use Dreamweaver or any kind of visual editor at all). Maybe our client opened those files using FrontPage, but I'd better go for a weird plugin they are using inside the server. Oct 19, 2012 at 17:11
  • Regardless, you have a code error and simply need to debug it. This is a development issue, not a system administration one. Oct 19, 2012 at 22:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .