RedirectIntermap

Summary: Allows redirects to intermap and external locations & implements silent 301 redirects
Version: 20190915
Prerequisites: PmWiki 2.2.58 or newer
Status: beta
Maintainer: Petko (original author: EemeliAro)
Categories: Links PHP72 PHP74

Allows redirects to intermap and external locations & implements silent 301 redirects.

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:)

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

  • 20190915 update for PHP 5.5/7.2, quotes are no longer required for the URL. Requires PmWiki 2.2.58 or newer. (Petko)
  • 20080213 — first release

See Also

Contributors

Comments

See discussion at RedirectIntermap-Talk

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.