TIP AutoRedirectPlugin is not installed on Foswiki.org.


automatically redirect a set of topics


This plugin lets you redirect certain URLs in an automatic fashion. A redirect is performed based on a list of rules that are executed in the given order, taking actions when matching all preconditions. Redirects can be performed for a single topic, all of a web, for specific users in a given context, or for an action for all topics and users.

This solition is specifically useful when some of your URLs have changed and you like to redirect users to the new location. Another important use case for public sites is to hide System, the Applications and all of its subwebs for unauthenticated users visiting the site. As your site will host a substantial amount of documentation available otherwise on the net, you may want to hide it from crawlers redirecting them elsewhere.

In general, it is always preferable to restrict view access using Foswiki's access control. However, sometimes this won't work out as you still need users to access content such as wiki applications using %INCLUDE or via view templates while blocking direct access to these wiki applications to everybody, except people of a application development group.


Let's have a look at the following example configuration stored in $Foswiki::cfg{AutoRedirectPlugin}{Rules}:

  ### rule 1
    "context" => "register",
    "target" => "none",
  ### rule 2
    "context" => "view",
    "web" => "Sandbox",
    "topic" => "AutoRedirectTest",
    "target" => "Main.WebHome",
  ### rule 3
    "wikiName" => "WikiGuest",
    "web" => "Applications.*",
    "target" => "Main.WebHome",
  ### rule 4
    "web" => "System",
    "topic" => 'UserRegistration|ResetPassword|ChangeEmailAddress|ChangePassword',
    "target" => "none",
  ### rule 5
    "web" => "System",
    "wikiName" => "WikiGuest",
    "target" => "Main.WebHome",

The first rule in the list prevents any redirect in case we are processing a user registration.

Rule (2) will redirect anybody visiting Sandbox.AutoRedirectTest to Main.WebHome. Note the use of the view context to still be able to access this topic via edit.

Rule (3) hides any unauthenticated (WikiGuest) user from visiting the Application web and all of its subwebs. This does not depend on any context being set thus fully blocking access to this part of your wiki. Once the user authenticated will he be able to access the Apllication webs.

Rules (4) and (5) block unauthenticated access to the System web, with the exception of those parts of the System web that are required for people to register, reset their password or perform any of these type of actions. Note the special target none in the third rule that implements the nessary exception to the rest of the System web being blocked from access in the fourth rule.

To summarize, each rule in the list may have the following properties:

  • target: either a topic to redirect to, or a fully quallified URL
  • context: a context identifier; most useful ones are: view, edit, save, isadmin, authenticated; see System.IfStatements for more
  • wikiName: regular expression to check the WikiName of the current user
  • web, topic: regular expressions to check the current location

All properties are optional except target as otherwise the system won't know where to redirect to.

Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.

Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button. Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will not show up in the search results.

You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
cd /path/to/foswiki
perl tools/extension_installer <NameOfExtension> install

If you have any problems, or if the extension isn't available in configure, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions for more help.



Change History

11 Jun 2018 add register script to default configuration; improved docu
12 Apr 2018 fixed some perl errors
09 Apr 2018 initial release
Topic revision: r3 - 11 Jun 2018, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy