Virtual Host Setup: Assign specific website to IP (default)

I just setup my droplet as a virtual host (LAMP + Ubuntu) and successfully added 5 websites! win! However, it seems to have chosen one of the five as the default when I visit my IP address directly. Is there a way to specify which site inside of /var/www/ the IP should default to?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted Answer

Look for the VirtualHost blocks in /etc/apache2/sites-enabled that you want to set as the default. Make the following change(s)

<VirtualHost  *:80>   or <VirtualHost *:443>


<VirtualHost _default_:80>   or  <VirtualHost _default_:443>

Make sure only one virtual host block is assigned the default (max one default per port). As you may already know, http URLs are usually assigned to port 80 and https URLs to port 443.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.