DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:redirect2

Redirect Manager (redirect2)

Compatible with DokuWiki

No compatibility info given!

plugin Redirect pages or media access by asking the client to refetch resources at the new location with redirect status 301 or 302.

Last updated on
2015-05-07
Provides
Action
Repository
Source

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to pageredirect, redirect

Tagged with cms, redirect

Description

Redirect access to pages and media files by asking the client to refetch resources at the new location with redirect status 301 or 302. The development of the Redirect2 plugin intend to provide feature like Redirect Directives of the Apache HTTP Server.

Installation

Install the plugin through the Extension Manager or Plugin Manager using the download URL above, which points to latest version of the plugin. Refer to plugin installation instructions.

Examples/Usage

Redirection rule map

The redirect rules can be defined throught the admin menu (redirect manager) and stored in conf/redirect.conf file. Lines that start # are just comments, and also text after # (at least one white space needs before #) are ignored as comment.

Each rule consists three fields – status, origin, destination – but the status field can be omitted assuming a temporary redirect status (302).

redirect.conf
# Example rederect map (redirect.conf)
# Status  Origin            Destination
   301     ns1:              ns2:ns2a:        # Rule 1
   302     ns1:ns1a:         ns3:             # Rule 2
   301     ns1:ns1a:page1    ns4:page2        # Rule 3
           ns1:ns1c:         page#lostpages   # Rule 4
 
# images and media files  
   302     :ns1:image.png    http://example.com/image2.png  # external
   301     :ns1:             :ns1:example.pdf
  • The origin and destination ID of page/media or namespaces must be absolute and cleaned (no specialchars, all lowercase).
  • Put : in front of the ID for media, otherwise any ID are assumed for pages.
  • If the origin field ends :, all pages/media files under the given namespace will be redirected. You may also put : to the end of destination ID to keep page/media name in the new namespace.

Redirection behavior

Every page/media access are checked against redirect rules until applicable one found by reducing sub namespace. This means that the order of redirect rules is less significant. For example, the access to the page ns1a:ns1b:page is to be tested in following sequence:

test test name reduced part description
1 ns1a:ns1b:page full pagename match test against rules
2 ns1a:ns1b: page check if namespace redirect
3 ns1a: ns1b:page check upper namespace redirect
4 : ns1a:ns1b:page check more upper namespace redirect

These are example behavior of page redirections when example redirect.conf file above used.

access page redirect destination applicable rule
ex.1 ns1:page4 ns2:ns2a:page4 Rele 1 at second test
ex.2 ns1:ns1a:page3 ns3:page3 Rule 2 at second test
ex.3 ns1:ns1a:page1 ns4:page2 Rule 3 at first test
ex.4 ns1:ns1b:page5 ns2:ns2a:ns1b:page5 Rule 1 at thrid test
ex.5 ns1:ns1c:anypages page#lostpages Rule 4 at second test

RedirectMatch (regular expressions matching rule)

:!: EXPERIMANTAL : The Regex test feature is disabled by default config setting.

You may need more complex redirect rules instead of simple pagename matching. The redirect2 plugin tentatively covers the limitted feature of RedirectMatch Directives of the Apache HTTP Server.

If the origin field is enclosed in % marks, a regular expression (regex) matching used instead of simple pagename matching.

# Example rederect map (redirect.conf)
# Status     Origin            Destination
302       %^:ns1:(.*\.pdf)$%    :ns2:$1
  • Any regex rules are to be tested against page/media ID if normal pagename matching sequence has failed.
  • Regex rules are used as defined order in the redirect conf file.
  • Regex tests will break when an applicable rule is found.

404 Redirect

The origin can be non-existing page, which should be redirected to specified destination. This however conflicts with NotFound plugin that will display a custom page for non-existing 404 page and prevent such redirect. The redirect2 plugin alternatively supports own 404 page.

Redirect Loop issue

Please do not define redirection loop in the redirect.conf rule file. Anyway, the redirect2 will stop if the destination page found in the breadcrumbs list, even thought it does not eliminate potential infinite redirect loop.


Configuration and Settings

The plugin can be configured with the configuration manager in the admin menu.

useRedirectMatch
:!: EXPERIMENTAL
enable regular expressions matching rule for redirect.
(default value = off)
show_msg Display a message about the redirection?
(default value = off)
msg_target Limit redirection message to …
(default value = 'only for admin')
404page Pagename to display when the page is not found (like http 404 response)
(default value = none)
logging enable logging. The redirection.log file is stored in data/cache directory.
(default value = off)

Development

Change Log from github repository

plugin/redirect2.txt · Last modified: 2015-05-07 15:36 by s.sahara