Topic on Project:Support desk

login directs to localhost

8
Phearson (talkcontribs)

Running 1.18, I originally installed the wiki in localhost in ubuntu, then backed up the database and files, and put them on a virtual machine. After setting up again, I tried accessed the wiki from the internal IP, and logged in. http://192.168.1.x/index.php?title=Special:UserLogin&returnto=Main+Page. After logging in, it takes me to http://localhost/index.php/Main_Page which does not work (nor should it). How can I fix this to go to the internal (and later external) IP instead? Phearson 00:11, 4 January 2012 (UTC)

Bawolff (talkcontribs)

In your LocalSettings.php, look to see if $wgServer is set to something. (if you change the path, you would also have to potentially look at $wgArticlePath and $wgScriptPath, but it appears from your message you only changed the server). Note if $wgServer isn't set, it means its auto-detected (and appearently auto-detected incorrectly), setting it explicitly shold fix your issue.

Phearson (talkcontribs)

This would accurate. The setting was set to "localhost" instead of the proper IP or Domain. Thank you.

Jayanth29 (talkcontribs)

@Phearson@Bawolff Sorry for bothering you after a decade, I am facing the same situation now. I am trying to connect to the server from a different server. The Main_Page is seen, but if I try to open any other pages, the URL redirects to localhost (I am trying to reach through the server's IP from another machine from the same segment). I changed $wgServer to the IP address of the server instead of localhost but the redirects persists. Any help would be appreciated.

Bawolff (talkcontribs)

Wow, a decade. Guess i have been doing this a long time.

Are you sure you have the right ip address. Generally changing $wgServer should be all you need. Its possible there could be something in your web server config, e.g. rewrite rules.

170.0.72.66 (talkcontribs)

$wgServer =  WebRequest::detectServer(); #case of localhost


i solved my problem doing this.

Bawolff (talkcontribs)

Note $wgServer =  WebRequest::detectServer(); does have some security risks (especially if using a frontend cache). We generally reccomend just putting the the protocol and domain name, because it is more secure, although the overall risk is minor.

Justinwik (talkcontribs)

Your localhost port may be different. Check the ports.

Reply to "login directs to localhost"