Manual:$wgUrlProtocols

From MediaWiki.org

Jump to: navigation, search
Site customization: $wgUrlProtocols
Defines the protocols which are supported and translated in HTML by the mediawiki parser.
Introduced in version: 1.5.0 (r10229)
Removed in version: still in use
Allowed Values: array of strings
string containing a regular expression before 1.6.0
Default Value: (see below)

Other settings: Alphabetical | By Function


Contents

[edit] Details

Defines the protocols which are supported and translated to clickable links by the mediawiki parser. External links added to the wiki which do not begin with one of these protocols are not allowed (they are simply rendered as text and do not become links, even if enclosed in square brackets).

Some examples that don't work (because "test://" is not defined as a valid protocol):

  • test://www.example.com
  • [test://www.example.com]
  • [test://www.example.com link text]

To allow links to local files (which may make sense in an intranet context), put this into your LocalSettings.php:

$wgUrlProtocols[] = "file:";

Note Note: some browsers, like Mozilla FireFox, will not follow file URLs on pages that have been loaded via HTTP. This is a security measure. See this mozillaZine article for more information, including some hints on how to overcome this restriction.

Note Note: most browsers do not support "remote file" URLs like file://host/share (only Internet Explorer handles these per default, a plugin is required for Firefox, see [1])

[edit] Default value

[edit] 1.6.0 and above

Since 1.6.0, the format of this setting is simply an array of allowed URL prefixes.

$wgUrlProtocols = array(
	'http://',
	'https://',
	'ftp://',
	'irc://',
	'gopher://',
	'telnet://', // Well if we're going to support the above.. -ævar
	'nntp://', // @bug 3808 RFC 1738
	'worldwind://',
	'mailto:',
	'news:'
);

This default value adds three new protocols to the ones covered by the earlier 1.5.x versions:

  • telnet://
  • nntp://
  • worldwind://

[edit] 1.5.x

In earlier versions the setting was a regexp expression which matched the beginning part of the URI; in other words, it is a set of prefixes separated by '|' (with '/' converted to '\/' because '/' has a special meaning in a regular expression.

$wgUrlProtocols = 'http:\/\/|https:\/\/|ftp:\/\/|irc:\/\/|gopher:\/\/|news:|mailto:';

This default value causes MediaWiki to render URIs with the following prefixes as external links:

  • http://
  • https://
  • ftp://
  • irc://
  • gopher://
  • news:
  • mailto:

[edit] Older Versions

If you need this functionality in older Versions:

There is the function replaceExternalLinks in ./includes/Parser.php. Just add a line for your protocol there.

[edit] See also

MetaWiki: URI schemes
Personal tools