Link to home
Create AccountLog in
Avatar of numberkruncher
numberkruncherFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Another 404 Question (PHP)

I am trying to create a simple 404 page.

When I use the 'header' functions, the web browser defaults to its default 404 page (except FireFox which does show my custom content).

When I don't use the 'header' functions, the web browser receives the usual 200 response which is obviously a bad thing.

I have several installations of WordPress on my development server, and the header method seems to work fine on those. WordPress returns its custom 404 page which the correct 404 status. So I cannot work out why my one is not working:
<?php header("HTTP/1.1 404 Not Found"); ?>
<!DOCTYPE html>
<html>
<head>
	<title>404</title>
</head>
<body>
	<div style="color: red">Page Not Found</div>
</body>
</html>

Open in new window

Avatar of numberkruncher
numberkruncher
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Another note, if I click "View Source" under web browsers where the content is not shown, the correct html is present. So why isn't it being shown to user?
Avatar of mydropz
mydropz

can you post more cod information on your php code that redirects to 404 page
At the moment I am just loading it directly:

http://localhost:8080/test.php
It also works fine in Safari...
ASKER CERTIFIED SOLUTION
Avatar of te-edu
te-edu
Flag of Serbia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Brilliant! That worked perfectly!

Is there any particular reason for this limitation?

I remember seeing something similar in WordPress, but I didn't realise that it was related to 404's
That is browser default value, smallest chunk used for transfer is 1024 bytes, for all download managers download upload scripts...
Thanks again!

Have a great Christmas!