How to setup 404 error message

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

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: [Jason] How to setup 404 error message

By gversion - June 12, 2012

Hi Jason,

Thanks for the reply.

I'd like to use the second code you provided:
redirectBrowserToURL("404.php");

Where would I insert that? Does it go in init.php or maybe into my listingDetail.php page?

Thanks again,
Greg

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