enabling 404 page


By default indexhibit doesn't come with a 404 error page, instead it diverts all the missing pages back to the index/home page.
For some users this is undesirable and for some visitors this is confusing.

This small adjustment to the code fixes this.

Please note that this code edits the base files for indexhibit, and does not come with any support. Please ensure that you make backups of all your files before doing this.


Create a 404 Page

Creating a page in indexhibit called 404 which contains your error message. And note down it's page ID which can be found in the URL of the editing page.

eg: ?a=exhibits&q=edit&id=4 would be id 4

edit index.php

Find the followiing lines of code in your index.php file.

if (!$rs) 
    header("HTTP/1.1 404 Not Found");
    // try again with site root
    $rs = $OBJ->db->fetchRecord("SELECT * 
        FROM ".PX."objects, ".PX."objects_prefs 
        WHERE url = '/'
        AND status = '1' 
        AND object = obj_ref_type");

    // we don't search engines indexing this
    header("HTTP/1.1 404 Not Found");

    // we need a formal error page
    if (!$rs) echo 'Page not found error here.';

and replace

WHERE url = '/'

WHERE id = 4

where 4 is the id of the page you created.

Save the file.

You should now have a working 404 error page.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License