Customize an Error Page
Steps
Create the wiki page that replaces one of the four error pages, none of which exists until you do, with administration rights on the wiki it is created in:
| Case | Page to create | Where | HTTP status |
|---|---|---|---|
| The wiki does not exist | XWiki.WikiDoesNotExist | the main wiki, because the template runs with the main wiki as its context | 404 |
| The page does not exist | XWiki.DocumentDoesNotExist | the wiki concerned | 404, and 400 when the same page answers a template that cannot be evaluated |
| The attachment does not exist | XWiki.AttachmentDoesNotExist | the wiki concerned | 404 |
| Access is denied | XWiki.AccessDenied | the wiki concerned | 403, or 401 when the request used basic authentication |
- Open the edit URL of the page you need (/bin/edit/XWiki/DocumentDoesNotExist for the missing-page case), which creates it.
- Write what your readers should see, and save. Anything a page can hold works.

- Open a page that does not exist. Your content is now what the reader gets, and the response is still a 404, so search engines and monitoring see no change.

FAQ
Can I replace the whole template instead of its content?
Yes, for three of the four cases: xwiki.wiki_exception (default wikidoesnotexist), xwiki.access_exception (accessdenied) and xwiki.attachment_exception (attachmentdoesnotexist) name the template each case renders, and xwiki.user_exception and xwiki.invalid_url_exception do the same for the inactive-user and invalid-URL screens. None of them appears in the shipped xwiki.cfg, and there is none for the missing-page screen, which comes from the skin. A replacement template runs instead of everything described here, so it is a skin-level change rather than a configuration one.
Where do I put the page in a subwiki?
In the subwiki itself, except for XWiki.WikiDoesNotExist: by the time that screen is rendered the wiki is precisely what could not be found, so it is read from the main wiki.