Extension:ExternalRedirect

Category:Unmaintained extensions#ExternalRedirect Category:Extensions without an imageCategory:Extensions without a compatibility policyCategory:GPL licensed extensions
MediaWiki extensions manual
ExternalRedirect
Release status: unmaintainedCategory:Unmaintained extensions
Implementation Parser function Category:Parser function extensions
Description Allows to make redirects to external websites
Author(s) Dāvis Mošenkovs (DavisNTtalk)
Latest version 1.2.1 (2022-02-21)
MediaWiki 1.27+Category:Extensions with manual MediaWiki version
Database changes No
License GNU General Public License 2.0 or later
Download Category:Extensions in GitHub version control
Category:All extensionsCategory:Extensions not in ExtensionJson

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

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

Configuration

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 {{FULLPAGENAME}}) 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'
);

The extension will redirect pages that are in the namespace(s) specified in $wgExternalRedirectNsIDs, as well as all of the pages specified in $wgExternalRedirectPages. Therefore you only need to set one of the arrays to get this to work, but you can set both if required.


Set this PCRE regex to achieve more strict destination URL validation. Allow ExternalRedirect only on write-protected namespaces/pages! Regular expressions are not always intuitive and there can be insecure redirects and various injection attacks exploitable on the target sites. This example would allow redirection to any page under https://www.mediawiki.org/ (this is not an example for a secure URL validation regex).

$wgExternalRedirectURLRegex = '/^https\:\/\/www\.mediawiki\.org\//i';

If $wgExternalRedirectURLRegex is specified it must be matched (in addition to $wgExternalRedirectNsIDs or $wgExternalRedirectPages) for the redirection to occur.


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

$wgExternalRedirectDeniedShowURL = false;

Security

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

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

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.

In version 1.2.0 $wgExternalRedirectURLRegex setting is introduced.

Category:Redirect extensions
Category:All extensions Category:Extensions in GitHub version control Category:Extensions not in ExtensionJson Category:Extensions not using extension registration Category:Extensions with manual MediaWiki version Category:Extensions without a compatibility policy Category:Extensions without an image Category:GPL licensed extensions Category:ParserFirstCallInit extensions Category:Parser function extensions Category:Redirect extensions Category:Unmaintained extensions