Custom 404 error page

It happens that pages are renamed, moved or deleted. However, search engines may still have these pages in their index or previous visitors may have bookmarked them. So if someone navigates to a page that does not (no longer) exist, CMSimple_XH sends the HTTP response code 404 and displays a corresponding (unformatted) message.

Create a new hidden page at the top menu level, for example, named “404”.

Customize this page as you like.


This 404 page should correctly send an appropriate status code for search engines.

Therefore, insert the following anywhere in the source code of this page:

<div>#CMSimple header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');#</div>


<div>#CMSimple http_response_code(404);#</div>

Now open the file cmsimple/userfuncs.php (description) with an editor and add the following lines:

(If this file does not exist yet, you have to create it first).

function custom_404() {
    header('Location: ?404');

So if a page that no longer exists is called up, then your just created page “404” appears and notifies the visitor. It is recommended to present a link to the start page and/or the sitemap on this self-designed error page.


The above only works if a non-existing CMSimple_XH page (with ?xxx) was actually called.

Example:[non-existent page]

For all other cases, an appropriate error handling should be entered in the .htaccess.

For more information about this, search with the search engine of your choice for the following keywords:

error document 404 htaccess