php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45818 Header location not work in 404 error page with Nginx
Submitted: 2008-08-14 08:56 UTC Modified: 2008-08-22 01:00 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: macroz at gmail dot com Assigned:
Status: No Feedback Package: CGI/CLI related
PHP Version: 5.2.6 OS: centos 5
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: macroz at gmail dot com
New email:
PHP Version: OS:

 

 [2008-08-14 08:56 UTC] macroz at gmail dot com
Description:
------------
Code header(Location:url) in 404 error page not work with nginx.

My webserver is Nginx 0.7.10 + php-fastcgi 5.2.6

Nginx conf code: 

error_page  404  /404.php;

Code in 404.php:

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


Curl -I a not exists file results (Nginx 0.7.10 + php-fastcgi 5.2.6)

curl -I http://www.abc.com/120.html
HTTP/1.1 404 Not Found
Server: nginx/0.7.10
Date: Thu, 14 Aug 2008 08:46:45 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.2.6
Location: http://www.abc.com/



This is work in apache+mod_php.
 
Curl -I a not exists file results (apache + mod_php)

curl -I http://www.abc.com/120.html
HTTP/1.1 301 Moved Permanently
Date: Thu, 14 Aug 2008 09:08:41 GMT
Server: Apache
X-Powered-By: PHP/5.2.5
location: http://www.abc.com/
Vary: Accept-Encoding
Connection: close
Content-Type: text/html



Reproduce code:
---------------
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.abc.com/");
?>

Expected result:
----------------
It will be location to http://www.abc.com/ when visite a not exist page.

Actual result:
--------------
Not location to http://www.abc.com/

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Apr 26 01:01:28 2025 UTC