IW. Can I replace undefined index response with a 404 error?

4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 16, 2012   (RSS)

By JeffC - July 13, 2012

I am using the Instant Website plugin

After a page has been removed and revisited it displays the php error 'Notice: Undefined index: name in...' message.

Instead of displaying the php error I would like to either:

Direct to a custom 404

or, even better

Replace the php error with a more friendly descriptive message such as 'this page has been removed'

Is this possible? Any help appreciated

Thanks
Jeff

Re: [Jeffncou] IW. Can I replace undefined index response with a 404 error?

By Jason - July 13, 2012

Hi,

I took a look through the Instant Website code, and in webiste_inti.php there is this block:

// show error message if no matching page is found
if (!$page) {
header("HTTP/1.0 404 Not Found");
print "<h1>404 Not Found</h1>";
exit;
}


This should give a 404 error when a page has not be retrieved. Could you give an example link to a page where you get the "Unidentified Index" error?

Also, so can change the message in the code at this point, or put in a redirect if you like.

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] IW. Can I replace undefined index response with a 404 error?

By JeffC - July 13, 2012 - edited: July 15, 2012

Hi Jason

The block of code you posted wasn't in my website_init.php. Maybe I have a earlier version of the addon or maybe I removed it by accident. Either way adding this code makes everything work. Thanks for your help.
Jeff