I recently tried to add a URL in my
/etc/hosts file, and because of many different attempts in the past, I realized I most probably have some extra lines in there which are not necessary.
I have read different information on the web and tried different syntax in the hosts file to finally have the 2 websites show at the correct URLs.
This is not for local development.
That was a few weeks ago. Here is what is looks like after my last failed attempt, I had to put it back to how it was :
127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters 126.96.36.199 servername.website-one.com 188.8.131.52 servername.another-site.com 184.108.40.206 servername.website-one.com servername.site-two.com servername.another-site.com 127.0.0.1 servername servername.site-two.com site-two.com 127.0.0.1 servername servername.website-one.com website-one.com 127.0.0.1 servername servername.another-site.com servername.another-site.com 220.127.116.11 test.website-one.com 18.104.22.168 website-one.com 22.214.171.124 site-two.com 126.96.36.199 another-site.com
Today I tried to add a 3rd website, and for some reason the 2 sites are being redirected to that one site. The problem is that this "redirection" (technically I don't think it should be called like a redirection). I am confused because there are various 'factors', or various files, that could have that effect.
As far as I understood, here is the list of "factors" that I should take into account for my problem :
/etc/hostsfile on the server ( apache2, ubuntu 16.04 )
- my DNS setting within my domain registrar account
- the configuration files for each site ( I know it can be specified individually with multiple sites in there "sites-available" and "sites-enabled" directories, or generally in one global file, but I can't remember which is the global file for all sites and where it is located
I also tried to use a sub domain
test.website-one.com without any success.
My hosts file is a mess. I remember reading somewhere that the server name should be used and it can be on one line, and then I red something else elsewhere.