I'm currently moving to an nginx server. I tried putting this in my 404 ErrorDocument named 404.php
:
<?php
header("Location: http://www.google.com/");
?>
If I now try to access http://mydomain.com/404.php
, this works as expected: It redirects me to Google. But once I try to access http://mydomain.com/iDoNotExist
, the 404 ErrorDocument is shown without redirecting me to Google.
This behavior seems weird to me. Is there any way I can fix this?
Edit:
Here's what curling the page gives me:
curl -I mydomain.com/404.php
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.2.1
Date: Sun, 05 Jan 2014 11:31:15 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.4.4-14+deb7u7
Location: http://google.com/
curl -I mydomain.com/iDoNotExist
HTTP/1.1 404 Not Found
Server: nginx/1.2.1
Date: Sun, 05 Jan 2014 11:33:49 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.4.4-14+deb7u7
Location: http://google.com/
Edit 2:
As asked by hakre, I'm coming from an Apache setup, and yes, I'm using Chromium. As for Apache, this used to work for all the Gecko and Webkit browsers and even console-based browsers such as Lynx. It would probably have worked for Internet Explorer as well, but I've never tried that (no Windows around here, phew).