RedirectIntermap

Summary: Allows redirects to intermap and external locations & implements silent 301 redirects
Version: 2008-02-13
Prerequisites: PmWiki 2.2.0-beta series, untested on 2.1.27 and earlier
Status: beta
Maintainer: EemeliAro
Categories: Links

Questions answered by this recipe

  • How can I redirect visitors to non-wiki pages in a relatively safe manner?
  • How can I disable the "Redirected from..." message?

Description

RedirectIntermap adds functionality to the default (:redirect:) directive by permitting you to use InterMap links in addition to normal PmWiki pages. Additionally it implements $EnableRedirectQuiet as defined in PITS 00919 in combination with the behaviour of the CustomRedirects recipe.

To install this recipe:

  • download redirect-intermap.phpΔ to your cookbook directory
  • add the following line to your config file:
    include_once("$FarmD/cookbook/redirect-intermap.php");

Configuration

The following variables may be set in your config file to configure the way RedirectIntermap works. The values shown are the defaults.

$EnableRedirectQuiet = 0;
Whether to show the "Redirected from..." message for permanent redirects. Set to 1 or TRUE to enable. If enabled, the markup (:redirect New.Page status=301:) will perform a silent redirect to New.Page, ie. the "Redirected from..." message won't be shown. Note that not defining status=301 will still result in showing the redirection message on the destination page.
$EnableRedirectIntermap = 1;
Whether to allow redirections to previously defined InterMap locations. By default, this won't allow redirections to places that aren't explicitly defined as intermap locations, e.g. redirects to http://example.com won't work.
$EnableRedirectExternal = 0;
Whether to allow redirects to any location. This is dangerous if your wiki has public edit access, so make sure you really want this before enabling.

Usage

Everything mentioned in the basic redirect documentation works as advertised, as well as everything mentioned in the cookbook recipe CustomRedirects provided that $EnableRedirectQuiet is enabled.

To redirect e.g. to this page, use:

(:redirect 'Cookbook:RedirectIntermap':)

NOTE: the quotes are necessary. This is due to the way PmWiki's ParseArgs function works and the way that intermap links have a ':' in them.

Setting status codes also works, for example:

(:redirect 'Cookbook:RedirectIntermap' status=301:)

To define your intermap links, see the PmWiki documentation on InterMaps.

Release Notes

  • 2008-02-13 — first release

See Also

Contributors

Comments

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.