Millar Posted September 1, 2006 Share Posted September 1, 2006 I want certain pages to return the 404 error page that the server automatically generates. I tried the following code and it didn't work, what am I doing wrong?My Code:[code]header("HTTP/1.1 404 Not Found");[/code]Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/19385-php-force-404-error/ Share on other sites More sharing options...
Jenk Posted September 1, 2006 Share Posted September 1, 2006 have you got a die/exit immediately after that? Quote Link to comment https://forums.phpfreaks.com/topic/19385-php-force-404-error/#findComment-84127 Share on other sites More sharing options...
Millar Posted September 1, 2006 Author Share Posted September 1, 2006 Yes. Quote Link to comment https://forums.phpfreaks.com/topic/19385-php-force-404-error/#findComment-84128 Share on other sites More sharing options...
Millar Posted September 1, 2006 Author Share Posted September 1, 2006 The whole file just looks like this -[code]<?header("HTTP/1.1 404 Not Found");exit;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/19385-php-force-404-error/#findComment-84148 Share on other sites More sharing options...
Zane Posted September 1, 2006 Share Posted September 1, 2006 If you're trying to create you're own Custom 404 Pages, you'll have to edit the 404.shtml in your Apache or IIS configurationMost of the time you can just have all you're error pages do the same thing and just send the error message to one of you're PHP scripts along with whatever information you want.But you have to do that in that 404.shtml fileThat is if that's what you're trying to do Quote Link to comment https://forums.phpfreaks.com/topic/19385-php-force-404-error/#findComment-84158 Share on other sites More sharing options...
Millar Posted September 1, 2006 Author Share Posted September 1, 2006 No. I have the error pages working fine. I just want PHP to output my servers 404 on a page that does. Exist so that I can force the error page for invalid query strings etc. Quote Link to comment https://forums.phpfreaks.com/topic/19385-php-force-404-error/#findComment-84162 Share on other sites More sharing options...
Zane Posted September 1, 2006 Share Posted September 1, 2006 Well, I guess if you're not going to have anything else on the error page other than......the 404you could just flat out redirect to ajflkjdslfkjsdlkajflakf.htmlwhich I'd assume doesn't existbut you'd do it through HTML and not a PHP function....meaningecho out[quote]<META http-equiv="refresh" content="0; URL=somerandomarrayofletters.html">[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/19385-php-force-404-error/#findComment-84167 Share on other sites More sharing options...
Millar Posted September 1, 2006 Author Share Posted September 1, 2006 Well id rather do it via the proper way. Anyone know why its not working? Quote Link to comment https://forums.phpfreaks.com/topic/19385-php-force-404-error/#findComment-84170 Share on other sites More sharing options...
GingerRobot Posted September 1, 2006 Share Posted September 1, 2006 Would it not be confusing for a user to send a 404 error for something like a bad query string? Would it not be better to give them a message saying what the problem was etc? Quote Link to comment https://forums.phpfreaks.com/topic/19385-php-force-404-error/#findComment-84189 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.