Editing /etc/hosts to use domain name instead of ip address
Yes, /etc/hosts associates IP addresses with hostnames
So, there are two things wrong with your line:
- 192.168.1.2:500 is an IP address and a port
- http://www.mydomainname.com is an URI and not a hostname
So, the line should be
192.168.1.2 www.mydomainname.com
You then access via http://www.mydomainname.com:500 from your browser of choice.
Yes.
- 192.168.1.2:500 is not an IP address. It is an IP address plus a port.
- http://www.mydomainname.com is not a domain name. It is a URL, part of which is a domain name.
/etc/hosts
maps IP addresses to hostnames, and vice versa. It is not a URL rewriting tool for WWW browsers. With it, one can map the name www.example.com
to the IP address 192.168.1.2, and that's it. No ports, schemata, paths or anything else enter into the matter.