Extension:ExternalRedirect

From mediawiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
ExternalRedirect
Release status: unmaintained
Implementation Parser function
Description Allows to make redirects to external websites
Author(s) Dāvis Mošenkovs (DavisNTtalk)
Latest version 1.0.2 (2013-07-14)
MediaWiki 1.21+
Database changes No
License GNU General Public License 2.0 or later
Download
Check usage and version matrix.

The ExternalRedirect extension allows to create redirects to external pages in wiki.

Use this extension only on write-protected wikis/namespaces! Abuse of this extension poses security risk.

Usage[edit]

A new parser function externalredirect with URL as first and only parameter is registered.

Place something like this on wiki page to make it redirect to external site:

{{#externalredirect: https://www.mediawiki.org}}

This allows, for example, to add external links to Categories (by placing pages with externalredirect in them).

Installation[edit]

  • Download, extract and place the file(s) in a directory called ExternalRedirect in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/ExternalRedirect/ExternalRedirect.php";
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration[edit]

Populate this array with NUMERIC namespace IDs where external redirection should be allowed. Only allow on write-protected namespaces! See Manual:Namespace for more info on namespaces and numeric IDs. This example allows redirects from help pages (12) and pages from custom namespace with numeric ID 500.

$wgExternalRedirectNsIDs = array(
    12,
    500
);

Populate this array with page names (see magic word Extension:ExternalRedirect) where external redirection should be allowed. Only allow on write-protected pages! This example allows redirects from the wiki pages about Warren G. Harding and the Teapot Dome Scandal.

$wgExternalRedirectPages = array(
    'Teapot_Dome_scandal',
    'Warren_G._Harding'
);

Whether to display link to redirection URL (along with error message) in case externalredirect is used where it is not allowed.

$wgExternalRedirectDeniedShowURL = false;

Security[edit]

This extension is meant for usage only on write-protected wikis/namespaces/pages. Here is an example how to add a name space editable only by the sysops. In "LocalSettings.php":

define("NS_MOVED", 500);
$wgExtraNamespaces[NS_MOVED] = "Moved";
$wgNamespaceProtection[NS_MOVED]=array('redirector');
$wgNamespacesWithSubpages[NS_MOVED]=false;
$wgGroupPermissions['sysop']['redirector']=true;
require_once "$IP/extensions/ExternalRedirect/ExternalRedirect.php";
$wgExternalRedirectNsIDs = array( 500 );

With version 1.0.2 there is introduced basic URL validation (using wfParseUrl()) which prevents seriously malformed URLs, but still allows redirection to arbitrary sites.