I can not log in when i use hostname in url

I can not log in when i use hostname in url

Hikaru Ohashi -
回帖数:5

 I'm now trying to put 3 phrases in the URL and log in. 

 In all three, of course, the administrator's name and password have not changed. 

 Two succeeded, but one just didn't.

 First  URL is  http://localhost/moodle. It can be logged in normally.

 Second, instead of 'localhost', I put ipadress like http:// 〇〇〇〇.〇.〇.〇/moodle. 

 This is done after  in the config .php where $CFG->wwwroot = 'http://localhost/moodle'; 

 Instead of 'localhost',  I put ipadress, save, and try logging in. It suceeded.


 Third, finally, i coul not log in to moodle.

 I have a hostname. This is the hostname of WindowsServer. In iis, when configuring bind to 'Default Web Site', the hostname is put in hostname. In config.php, I edited $CFG->wwwroot = 'http://hostname/moodle';. In the driver\etc\hosts file of WindowsServer, I also set the 'ipadress hostname' in last line. As a result, the first login screen in the ' http://hostname/moodle' appears without any problems. And next terrible thing happened.  When I put localhost and ipadress in the url, I entered the admin ID and password, and pressed the login button, then I was logged in, but for some reason, I could not log in . Oh my gosh. If I change it to 'http://hostname/moodle' 'http://localhost/moodle' and restore the config .php and iis Default Web Site binding settings before editing, I can log in normally. Only when hostname is set as a URL, I cannot proceed from the login screen. What should I do? I'm really in trouble.


回复Hikaru Ohashi

Re: I can not log in when i use hostname in url

Ken Task -
Particularly helpful Moodlers的头像
I probably shouldn't respond to this as I don't do Windows anymore, but think this issue stems from instructions on installing Moodle on Windows where it said to use localhost.   You used the browser on the server and not a browser from a workstation.

If your moodle is to be accessed from the internet - both public and private internets - your server's IP address needs to have at least an A record in DNS (both public DNS an PRIVATE if your server is hosted inside a private network).

All computers on the internet use a host file that maps fully qualifed domain names to an IP address with a shortcut alias.   But that host file isn't DNS and no other workstations on your private LAN/WAN nor any of us here in forums can query your host file.

The other item .... once you have a FQDN for server it's strongly suggested to get a valid certificate for your server so you can run the site as https://.

Those two things should be prerequisites to the install of Moodle.

If you installed your Moodle using http://localhost that not only gets into config.php file as wwwroot but that is also then used to build internal links in moodle ... such as logging on and then being directed to the front page or how ever you have set that up.

So once you get a FQDN in DNS and a cert, you will have to run search and replace tool in moodle to replace all the references in the DB that pointed to http://localhost/ to https://yourFQDN/


Also ... please post an issue in one forum only - not two forums with same question/issue.

Fix this issue and think your other posting about SSO might be solved as well.

'SoS', Ken
 


回复Hikaru Ohashi

Re: I can not log in when i use hostname in url

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
I have the suspicion that the 'hostname' you are talking about is the (Windows-internal) single-word WINS host name. The Internet (thankfully) works differently. The 'hostname' for Moodle through the internet is a FQDN https://en.wikipedia.org/wiki/Fully_qualified_domain_name.