Manual talk:$wgServer
Add topicEmpty value for $wgServer?
[edit]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
[edit]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)
- It is superfluous for versions, which are no longer supported. Also, these versions often have known security holes and additionally there is no point in cluttering manual pages with such outdated information. A huge mess of historic information also is disturbing and obstructs the view on real and current problems. --87.123.28.202 12:34, 25 May 2016 (UTC)
Use server name and port from request URL?
[edit]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.
- In v.1.35 it is necessary to include it but leave it empty like so:
## The protocol and server name to use in fully-qualified URLs $wgServer = "";
httpd.conf
[edit]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
[edit]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? --[[kgh]] (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
".
- Are you sure it was version 1.17.3? Please check for the following lines in "
## The protocol and server name to use in fully-qualified URLs \$wgServer = \"{$this->values['wgServer']}\";
- 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 --[[kgh]] (talk) 19:13, 28 March 2012 (UTC)
- I have tested this and the installer in version 1.17.3 does not set this variable in "
- I copied them from version 1.18.0 of the same file. Allen4names (talk) 17:03, 28 March 2012 (UTC)
Symptoms of misconfigured $wgServer
[edit]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
[edit]There's a nice discussion of $wgServer at phabricator:T42679. --MZMcBride (talk) 03:34, 2 October 2012 (UTC)
Force https
[edit]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)
- Seems like something is wrong with your RewriteRules. $wgServer only sets the server portion of URLs, which MediaWiki creates. It does not trigger any redirect. --87.123.28.202 07:43, 25 May 2016 (UTC)
- In case anyone doesn't know how to do it, this does the trick at the end of the rewrite rules, this is from our encyclopedia, you can see it in action here: http://encyclopediaofbuddhism.org
- redirects to https://encyclopediaofbuddhism.org
## The protocol and server name to use in fully-qualified URLs $wgServer = "https://encyclopediaofbuddhism.org"; # https://www.mediawiki.org/wiki/Manual:$wgEnableCanonicalServerLink $wgEnableCanonicalServerLink =true; # Also had to modify .htaccess to add # # RewriteCond %{HTTPS} off # RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] # see https://wiki.apache.org/httpd/RewriteHTTPToHTTPS # # Needs to be added at the start of the file (not at the end). # Idea is that since the code works fine from then on with https # then you just need to change the url to https and then let it # flow through the rest as before
- - also need to make sure .htaccess has
# RewriteEngine On
- before that point, usually will do.
- Our site only has the wiki installation on it, you would need a more complex .htaccess if parts of it were http and parts https.
- Robertinventor (talk) 13:27, 1 October 2018 (UTC)
upgrade 1.31 to 1.35 issue
[edit]fyi,
my LocalSettings.php in 1.31 didn't had this value set. In 1.35 it seems required now. I tried false and "" but didn't work so end up using the FQDN (so can't test with direct IP)
TiloWiki (talk) 23:39, 22 June 2021 (UTC)
LocalHost and IP?
[edit]I upgraded MediaWiki from 1.26 to 1.36.1. Is it possible to set the $wgServer value to accept LocalHost and an Internal IP (eg, 192,168,2,x)? Can I set the value to the following in 1.36.1?
$wgServer = WebRequest::detectServer();
--65.93.20.129 05:29, 26 June 2021 (UTC)