Last modified: 2014-02-12 23:32:52 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 T48495, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 46495 - Auto-detect the server name so as to access the wiki both via localhost and via ip
Auto-detect the server name so as to access the wiki both via localhost and v...
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
Installer (Other open bugs)
1.20.x
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-23 21:23 UTC by Luis Felipe Schenone
Modified: 2014-02-12 23:32 UTC (History)
4 users (show)

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


Attachments

Description Luis Felipe Schenone 2013-03-23 21:23:15 UTC
Today I turned my computer into a home server, so now I can access my localhost by entering my public IP address, say http://123.123.123.123/ It works fine, I can access my localhost and all the websites stored in it.

Then I went to http://localhost/wiki/ and installed a wiki there. It all went fine. However, when I tried to access the wiki from http://123.123.123.123/wiki/, I got redirected to http://localhost/wiki/

So I tried installing the wiki again, this time at http://123.123.123.123/wiki/. What happened was that I could access the wiki through http://123.123.123.123/wiki, but when I went to http://localhost/wiki/, I got redirected to http://123.123.123.123/wiki/

So I looked into LocalSettings.php, and found that the server name (either http://123.123.123.123/ or http://localhost/) was hard coded at $wgServer. I tried changing its value to $wgServer = 'http://' . $_SERVER['SERVER_NAME'], and was glad to find out that now I could access my wiki from both http://123.123.123.123/wiki/ and http://localhost/wiki/

It seems like an easy solution, but I would like other developer's opinion. Should I push this change? Is there some reason I'm not seeing for keeping the server name hard coded?

Two notes:
* I noticed that if I run the installer from http://localhost/wiki/, then I said, I can't go to http://123.123.123.123/wiki/ without getting redirected, but I CAN go to http://123.123.123.123/wiki/index.php/Main_Page and not get redirected. Also, I can then navigate through the wiki without getting redirected. Same if I run the installer from http://123.123.123.123/wiki/ and then go to http://localhost/wiki/index.php/Main_Page
* I tried the same steps with a WordPress installation, and WordPress had no problems.
Comment 1 Daniel Friesen 2013-03-25 09:17:24 UTC
You could also just remove $wgServer if you want the autodetection. That code is still inside of MW for compatibility.

We used to not set wgServer and let the domain name be autodetected all the time.
We purposefully changed the installer to now set $wgServer because it can cause problems when not set.

And you'd best rethink your praise of WordPress. In this cause WordPress' track record is actually worse. You may not see yourself being redirected. But it's hardcoding complete urls all over the place as you use it. If you actually used WordPress in that state you'd eventually find that your blog is completely messed up. With plenty of links on the blog that are dead on either side you view it from.

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


Navigation
Links