1

I have set up a website (www.test.com) using Apache2 on Ubuntu 14.04.

However I can only access the website after disabling the network connection (using nmcli nm enable false). If I keep the network connection, Firefox always opens the internet version of it.

How can I make my site a higher priority than the internet version with network connected?

2 Answers 2

2

There are two ways to approach the problem, but the easy method is to edit your /etc/hosts file to make www.test.com map to local addresses instead.

  1. In the Terminal, run the following: sudo nano /etc/hosts
  2. Add a line in the following format: 127.0.0.1 www.test.com test.com
  3. Exit text editor
  4. Nuke your browser cache (this means, delete all cached pages in your browser).
  5. Try the site, it should load the local variant.
1
  • Ehheheh this answer was posted from my phone, and Sledge and I seem to have posted the same thing within a short time of each other xD
    – Thomas Ward
    Aug 5, 2015 at 3:08
2

You have to add it inside the hosts file, which is located in /etc. Open it with your favorite console text editor (with root privileges by adding sudo in front of the command) and add the following text on a new line

127.0.0.1 test.com www.test.com

For example if you use mcedit the command will be:

sudo mcedit /etc/hosts

This assumes that apache is also running on the local interface (as it is by default). If you have disabled this functionality, you have to change 127.0.0.1 with the IP address apache is working on.

You can test if everything works correctly with the ping command ping test.com

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .