Site accessible through IP and domain name -- is this a problem?

Posted November 10, 2013 4.4k views
I have setup a LAMP environment on my droplet. My site is accessible through the IP address as well as the domain name. Is this an indication that I set up Apache incorrectly? I want my site accessible through the domain name only.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers
You can enable NameVirtualHost and divert all the traffic by hosts.
That way you can add multiple domain names to one Apache server.

Example configuration:

NameVirtualHost *:80

DocumentRoot /var/www/mywebsite

What's the desired configuration?
How would you like it to act?
It is default configuration. Read about virtual hosts
"Is this an indication that I set up Apache incorrectly?"


" I want my site accessible through the domain name only."

Check out How To Set Up Apache Virtual Hosts on Ubuntu 12.04 LTS.
by Etel Sverdlov
This tutorial shows you how to set up a new directory, how to grant the correct permissions, how to add content to a new page, how to turn on virtual hosting, and how to, if needed, set up local hosts. Virtual Hosts are used to run more than one domain off of a single IP address and allows you to run multiple sites off of a single DigitalOcean droplet. This tutorial describes how to set up virtual hosts with Apache.