Last modified: 2010-05-15 15:28:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T3077, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 1077 - Wrong redirects if $wgServerName not set.
Wrong redirects if $wgServerName not set.
Status: RESOLVED DUPLICATE of bug 61
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.3.x
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-12-11 23:38 UTC by Bodo Thiesen
Modified: 2010-05-15 15:28 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Bodo Thiesen 2004-12-11 23:38:41 UTC
In non-public environments, servername may be localhost or something like that. If 
I now try to set up mediawiki, I get redirected to localhost in some cases, which 
is bad[TM]. Current implementation tries to guess $wgServerName by looking at 
SERVER_NAME and HOSTNAME and falls back to 'localhost' if either fails. The 
env-vars may each be set to localhost, which is wrong, if I use any other system to 
access the wiki. HTTP_HOST contains the domain or ip address used in the uri when a 
page is requested. So try first to obtain $wgServerName form there, and only fall 
back to any of the other ways if that fails.

Regards, Bodo.

The patch is also available for download at 
http://bothie.sharedaemon.org/temp/mediawiki-1.3.8-bt1.diff - just for the case of 
problems with tabs etc.

diff -ur mediawiki-1.3.8/includes/DefaultSettings.php 
mediawiki/includes/DefaultSettings.php
--- mediawiki-1.3.8/includes/DefaultSettings.php        2004-11-16 
00:59:13.000000000 +0100
+++ mediawiki/includes/DefaultSettings.php      2004-12-12 00:18:17.000000000 +0100
@@ -14,8 +14,11 @@
 $wgSitename         = 'MediaWiki'; # Please customize!
 $wgMetaNamespace    = FALSE; # will be same as you set $wgSitename
 
-
-if( isset( $_SERVER['SERVER_NAME'] ) ) {
+if (isset( $_SERVER["HTTP_HOST"] )) {
+       # First try to get the ServerName from the only point, which is 
+       # correct in ANY case. Only if that faily, try other guesses.
+       $wgServerName = $_SERVER["HTTP_HOST"];
+} elseif( isset( $_SERVER['SERVER_NAME'] ) ) {
        $wgServerName = $_SERVER['SERVER_NAME'];
 } elseif( isset( $_SERVER['HOSTNAME'] ) ) {
        $wgServerName = $_SERVER['HOSTNAME'];
Comment 1 Brion Vibber 2004-12-11 23:49:03 UTC

*** This bug has been marked as a duplicate of 61 ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links