How to setup 404 error message

5 posts by 2 authors in: Forums > CMS Builder
Last Post: June 14, 2012   (RSS)

By gversion - June 11, 2012

Hello,

Currently when a listing is deleted and therefore the web page no longer exists, a blank white page is just displayed with the following message, "listingsRecord not found!"

Is there any way I can change this web page so that I can display a 404 error message, with the correct 404 or 410 HTTP response code?

Thank you,
Greg

Re: [gversion] How to setup 404 error message

By Jason - June 12, 2012

Hi Greg,

There are a couple of approaches. If you just need the 404 header, you can use the dieWith404() function. For example:

dieWith404("Listing not found!");

If you have a 404 page that you would like to send them to, you can redirect them like this:

redirectBrowserToURL("404.php");

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [gversion] How to setup 404 error message

By Jason - June 13, 2012

Hi Greg,

First you need a file to redirect them to. 404.php is just an example, you can replace this with whatever file you like.

Basically, you do the redirect after you've determined that a listing wasn't found.

For example:

if (!$listing) {
redirectBrowserToURL("404.php");
exit
}


You would just replace your current die() statement with the redirect code.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] How to setup 404 error message

By gversion - June 14, 2012

Hi Jason,

That's excellent, thank you for your help.

Regards,
Greg