Manual:$wgServer

From MediaWiki.org
Jump to: navigation, search
General Settings: $wgServer
The base URL of the server.
Introduced in version: pre 1.1.0
Removed in version: still in use
Allowed values: URL prefix (protocol, host, optional port; no path portion)
Default value: (dynamically created)

Other settings: Alphabetical | By Function

The base URL of the server, including protocol and without the trailing slash (eg, http://www.mediawiki.org). Since 1.18 MediaWiki has also supported setting $wgServer to a protocol-relative url (eg, //www.mediawiki.org). This is used for supporting both HTTP and HTTPS with the same caches by using links that work under both protocols. When doing this $wgCanonicalServer can be used to set the full url including protocol that will be used in locations such as emails that don't support protocol relative urls.

This is used when producing fully-qualified URLs pointing to the wiki, for instance:

  • HTTP redirects on edit and to canonical URL spellings
  • print footer
  • links to articles from RSS/Atom feeds
  • and more!

Autodetection[edit | edit source]

When $wgServer is not set the default value is calculated automatically. Some web servers end up returning silly defaults or internal names which aren't what you want; for instance the ServerName directive in Apache's httpd.conf may not be set or detected properly by the system, leaving you with an unexpected http://localhost. It's always good to configure the web server properly. But you are also always strongly recommended to set $wgServer explicitly in your LocalSettings.php as there are other bugs that may arise from allowing it to be auto-detected, such as cache pollution.

History[edit | edit source]

1.18[edit | edit source]

The installer sets this variable in LocalSettings.php. However, if it is not set in LocalSettings.php, the server name will be detected at run time using the method WebRequest::detectServer().

See Also[edit | edit source]

Language: English  • français • 日本語 • português do Brasil • русский