404 (Page does not exist) Redirect

By tsangktsangk

Description

Note: as of the 19th November 2012, Wikidot has implemented a full solution which no longer requires this snippet. View their solution here.

While Wikidot is a wiki platform, some users might wish to show users a more useful message when a page doesn't exist. With this snippet, you can redirect users to a custom 404 page and still get access to create the page using the standard /edit/true URL tags.

Following the tradition of James' JS-based snippets, I too will show the "framework".

Attributes

attribute required allowed values default description
url yes valid URL or website address none Specifies the URL to redirect the user to when a page doesn't exist

Code

You will need to copy the code into the side bar (usually nav:side):

[[include :snippets:404-redirect
|url=http://www.wikidot.com
]]

Link to edit

You can also include a link to create the page that wasn't found. Simply add the following line to your 404 page:

[[include :snippets:404-link
|label=Click here to create the page
|width=200px
|height=30px
]]
[!-- Note, all fields are optional --]

In action

It's currently in action on the Community site as well as in my personal sandbox:

Wikidot Community:
thispageblahblah — this page doesn't exist, it'll be redirected to the 404 page
404 — the 404 landing page
Community Home Page — the page exists, so we're not redirected to the 404 page :)

My Sandbox:
npr:pageexist — this page exists, and isn't redirected to the 404 page.
npr:doesntexist — this page doesn't exists, and will be redirected to the 404 page.

Changelog

  • 27th Aug 2012: decreased iframe size by 124 bytes. Hopefully this will make redirection that little bit faster.
  • 28th Aug 2012: added "create page" functionality in 404 page. Simply include [[include :snippets:404-link…

Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by tsangk

Custom HTML Blocks - 25 Oct 2012 11:30
URL Title with Slash Redirect - 16 Feb 2012 01:49
Syntax Highlighter - 16 Feb 2012 01:45
Conditional Blocks - 15 Feb 2012 00:36


Rate this solution

If you think this solution is useful — rate it up!

rating: +6+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License