Jump to content

Using the header() function as a 404 redirect


Recommended Posts



I have a database driven site, but at the moment when a bad request is given, there is just a message saying "sorry no records found"


I have changed it a bit so that there is a header() redirect, and my plan is to respond with 404 and serve a nice looking 404 page with a sitemap on it for my users.


I can't seem to figure out how to do this though:


header('HTTP/1.0 404 Not Found');


Does not work, and the page loads as normal, which is not what I want. Weirdly if I change to Location: type header redirect it works as i expect.


If anybody could let me know why this isn't working, I would be very grateful!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.