|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|
Defines the URL protocols that MediaWiki will recognize as valid in wfParseUrl(). This is used in lots of places. The most visible effect is it determines what protocols are allowed for external links: unrecognized protocols are ignored, no link is generated. However, it's used in many other places too, including the code for Special:LinkSearch, and utility functions like
wfParseUrl() that are used in a wide variety of different places.
Some examples that don't work (because
"test://" is not defined as a valid protocol):
- [test://www.example.com link text]
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: Most browsers do not support "remote file" URLs like file://host/share (only Internet Explorer handles these per default. For Firefox, a plugin is required or use exactly 5 slashes like file://///host/share, see )
Warning: In MediaWiki 1.20.2+, adding
"file:" without trailing slashes to
$wgUrlProtocols will break image embedding using the
[[File:Image.jpg]] syntax. This is a known bug related to a change that made URL protocol matching case-insensitive. As a workaround, use
"file://" instead of
"file:" as shown below.
To allow links to local files (which may make sense in an intranet context), put this into your LocalSettings.php:
$wgUrlProtocols = "file://";
Usually you only want to add protocols without trailing slashes to this array.
The default value is
$wgUrlProtocols = array( 'bitcoin:', 'ftp://', 'ftps://', 'geo:', 'git://', 'gopher://', 'http://', 'https://', 'irc://', 'ircs://', 'magnet:', 'mailto:', 'mms://', 'news:', 'nntp://', 'redis://', 'sftp://', 'sip:', 'sips:', 'sms:', 'ssh://', 'svn://', 'tel:', 'telnet://', 'urn:', 'worldwind://', 'xmpp:', '//' );
The default protocols should all be safe to click on (no evil side effects), and removing a protocol from the list will cause URLs using those protocols to become unrecognized in many places throughout the software, e.g. in API calls and in page content. In particular, removing 'http://' or other common protocols will probably break huge amounts of stuff.
Certain protocols may collide with the name of a namespace in your wiki, e.g. you may have a "News" namespace, which collides with the "news:" protocol. In order to allow links to this namespace, you can do something like this:
$wgUrlProtocols = array_diff($wgUrlProtocols, array('news:'));