Manual talk:$wgServer

If you've just installed MediaWiki, and you are getting submit errors when you attempt to edit a page, and get "The page cannot be found" with the URL specified as

h ttp://localhost/mywikipedia/index.php?title=Page&action=submit

check the apache-error.log to see if you see an error such as:

[error] [client 10.32.223.71] File does not exist: C:/wamp/www/mywikipedia/ localhostlocalhost

Note how "localhost" is listed twice. Go into your www\mywikipedia\LocalSettings.php file and change $wgServer from:

$wgServer = 'localhost';

to

$wgServer = '';

Restart the servers.

This will clear the error and have edit/submits work properly.


 * That would produce incorrect URLs; instead simply format the value correctly! Include the protocol part of the URL, like so: 'http://localhost'. --Brion VIBBER 23:08, 17 November 2006 (UTC)

History
Is the history section of this page really neccessary, if I were coming to here for information about this setting (the primary purpose of this manual) a section on the history would be quite irrelevant. Any developer looking here would probably find it equally useless as the current version appears to work fine. Appoligies if I am overlooking something. Lcarsdata (Talk) 15:05, 17 March 2007 (UTC)


 * It matters if you are not using the latest version of MediaWiki. --HappyDog 13:55, 2 April 2007 (UTC)

Use server name and port from request URL?
Is there any way to make Mediawiki use the server name given in the request URL? E.g. if I'm accessing the wiki as http://foo/wiki then I want all URLs in redirects etc. to be http://foo/wiki. However if I use http://bar:8080/wiki I want all URLs generated to be http://bar:8080/wiki. (Yeah, this is to allow tunneling through various networks in weird ways.)


 * I was having the same problem. It took me an hour of reading through support requests mentioning $wgServer to find a one-line, off-handed mention of the fact that, if you just comment out $wgServer, it will autodetect on every request.  Of course, this makes it so that it will auto-detect for any url, not just pick from a restricted list, so it might not be exactly what you want, but it should be a step in the right direction.

httpd.conf
It would be helpful if there was a link to a resource on configuring httpd.conf correctly.

Set by installer/Automatic setting of this parameter
This variable is set by the installer in version 1.18 but I do not think this is also true of version 1.17. If I am wrong please specify the first version (ie 1.17.2) this is in. Allen4names (talk) 16:37, 28 March 2012 (UTC)
 * I changed to 1.17 since a fresh install of 1.17.3 set this parameter. Was it backported? --&#91;&#91;kgh&#93;&#93; (talk) 16:38, 28 March 2012 (UTC)
 * Are you sure it was version 1.17.3? Please check for the following lines in "mediawiki-1.17.3/includes/installer/LocalSettingsGenerator.php".

\$wgServer          = \"{$this->values['wgServer']}\";
 * 1) The protocol and server name to use in fully-qualified URLs
 * I copied them from version 1.18.0 of the same file. Allen4names (talk) 17:03, 28 March 2012 (UTC)
 * I have tested this and the installer in version 1.17.3 does not set this variable in "LocalSetting.php". Allen4names (talk) 17:48, 28 March 2012 (UTC)
 * Hmmm... I can remember my post but not this thread. Senior moments. O_o I could swear that is was added to the LocalSettings.php. However, if you just tested it I must be wrong. I guess it is safrer to keep 1.18.0 Thank you for checking and looking into this matter. Cheers --&#91;&#91;kgh&#93;&#93; (talk) 19:13, 28 March 2012 (UTC)

Symptoms of misconfigured $wgServer
There is a certain problem I've seen several times, which can be caused by a misconfiguration of this setting and perhaps by other causes as well. What happens is that the sidebar and logo go away and much of the other formatting goes away too. Here are a couple screenshots to illustrate. Leucosticte (talk) 04:27, 18 September 2012 (UTC)
 * If this is caused by incorrect $wgServer, then the base URL is wrong making the stylesheets, logo link and mostly all internally links point to nowhere leading to the symptoms you describe. --88.130.79.83 13:12, 25 January 2015 (UTC)
 * There still are reports from users, who had this problem at Support Desk. Obviously they do not find this page or they at least do not find the information on it. I will rework the content to point this issue out more clearly - currently it is really hidden somehow. --88.130.64.121 10:11, 9 July 2015 (UTC)

Discussion of $wgServer on Phabricator
There's a nice discussion of $wgServer at T42679. --MZMcBride (talk) 03:34, 2 October 2012 (UTC)

Force https
I acquired a SSL-certificate and I would like to use it for every user on my wiki. I changed $wgServer to https://example.com but that doesn't force https. I tried every trick in the book for .htaccess but then when I enter my wiki through any page I am being referred to the frontpage. It seems the redirect cuts off everything after the hostname. I tried at least a dozen solutions - does anybody have a working solution for this? --Kaffeeringe (talk) 20:32, 24 March 2016 (UTC)