php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48793 Setting error_log in php.ini causes redirection
Submitted: 2009-07-03 18:43 UTC Modified: 2009-07-09 20:17 UTC
From: memoimyself at yahoo dot com dot br Assigned: fb-req-jani (profile)
Status: Closed Package: *General Issues
PHP Version: 5.3.0 OS: WinXP SP3
Private report: No CVE-ID: None
 [2009-07-03 18:43 UTC] memoimyself at yahoo dot com dot br
Description:
------------
Set-up: WinXP SP3, PHP 5.3.0, Apache 2.2.11

This is a truly bizarre problem, but I've done a lot of testing and do believe it's a bug.

A few days ago I updated my test server to PHP 5.3.0. After doing that, even though Apache had not been touched in any way, all URLs containing 'localhost' pointing to PHP files (e.g. 'http://localhost/whatever.php') started being redirected to 'www.localhost.com' (e.g. 'http://www.localhost.com/whatever.php').

At first it didn't even occur to me that the problem could have anything to do with PHP. I checked 'c:\windows\system32\drivers\etc\hosts' and it still contained a line for '127.0.0.1 localhost'. I checked my network adapter configuration and IPv6 had not been added as a protocol. My Apache configuration files were untouched.

I spent two days searching high and low for a possible cause, and along the way realized that the problem only occurred when PHP was involved: HTML files were being served without any redirection issues.

When I replaced php.ini with an old version from a backup and everything went back to normal, so I fired up a diff application and, bit by bit, started replacing the contents of the newer php.ini with lines from the old one.

I finally isolated the problem: the error_log line, which specified the absolute path to a log file (the same path that had been working fine with previous PHP versions). When the line is commented out, the redirection problem goes away.

I double-checked the existence of the log file and made sure it was writable. I then tried moving it to a different directory (updating php.ini accordingly), but that didn't work either. I also tried changing the path from "C:\Apache\logs\php_error.log" to "file:///C:/Apache/logs/php_error.log" and that did make the redirection problem go away, but no errors are actually logged, even though 'log_errors' is properly set to 'On'. If I set error_log back to "C:\Apache\logs\php_error.log", the redirection issues comes back.

Reproduce code:
---------------
Line in php.ini:

error_log = "C:\Apache\logs\php_error.log"

Expected result:
----------------
Errors should be logged as usual.

Actual result:
--------------
Errors are not logged. Whether or not code contains any errors, browser (both IE and Firefox) gets redirected from http://localhost/path/to/script to http://www.localhost.com/path/to/script.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-04 20:02 UTC] ninzya at inbox dot lv
Is your apache server on 8080 port?
 [2009-07-04 21:10 UTC] memoimyself at yahoo dot com dot br
Q: Is your apache server on 8080 port?

A: Nope, 80. My httpd.conf is pretty straightforward and uses default values. Please note that Apache serves pure HTML (as well as other files) normally. Things only get weird when PHP is involved AND error_log is set in php.ini.
 [2009-07-05 13:55 UTC] ninzya at inbox dot lv
I guess this is your browser's activity. PHP itself does not deal with 'user hint' redirections by prepending or appending www's and com's to the requested host. Your browser, probably, reacts to HTTP 500 error code and attempts a redirection to probably valid location of www.localhost.com. Anyway, look at the access.log of apache, see what's the apache's response code to your request. Another guess may be is that the PHP is failing (segfaulting) with error_log, which leads to connection interruption between your browser and web server. Then browser attempts to connect to www.localhost.com... Anyway, redirection is being done by your browser.
 [2009-07-07 15:38 UTC] jani@php.net
Check if there are some crashes happening. (most likely there are since others have reported the same..)
 [2009-07-07 22:13 UTC] memoimyself at yahoo dot com dot br
[Re: ninzya 5 Jul 1:55pm]

You're right, my browser(s) is very likely responsible for the redirection. Firefox 3.0.11 redirects; IE 8 reports the page as inaccessible; and Opera doesn't do anything.

But the fact remains that something is causing the problem, and that something involves PHP -- and only when error_log is set in php.ini. As I've previously reported, Apache continues serving pages/files other than PHP normally.

I'm aware that PHP interacts with Apache and even with the OS so that the problem could be due to a combination of factors. But I had never had this problem before, and the only significant change in my set-up has been the upgrade of PHP from 5.2.8 to 5.3.0. In other words, something seems to have changed in PHP that may be causing this strange problem.
 [2009-07-07 22:17 UTC] memoimyself at yahoo dot com dot br
[Re: jani@php.net 7 Jul 3:38pm]

What crashes, specifically, should I watch out for? Applications do crash on occasion, just as they do on any box and with any OS (in my not very limited experience). But I have not experienced a surge in application crashes since upgrading to PHP 5.3.0, and have not had a single major OS crash so far.
 [2009-07-08 20:38 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Should be fixed now..
 [2009-07-08 23:28 UTC] memoimyself at yahoo dot com dot br
I've just installed the CVS snapshot and the problem I reported has indeed been fixed. Thank you very much!
 [2009-07-09 20:17 UTC] jani@php.net
Yup, the fix for bug #48247 fixed this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 10:01:30 2024 UTC