Two domains the same space in the server

I have two domains: I would like both domains are in the same virtual hosts targeted, that is, that if I enter the domain 1 shall be the website and if I open domain 2 open the same site.

This is solved in the network of Digital Ocean or in my Virtual Host server.

Show comments

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.

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.

Nice! Problem resolved!

Hey there,

This is going to depend on what webserver you are running, which you do not mention. I’ll give you the answer in general terms which should be good enough for you to google how to configure in your specific application.

What you want to do is setup a VirtualHost with your primary domain and a few alternate domains. I’ll give an example config below for Nginx as that is my webserver of choice.

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;



The important bit to look at there is the “server_name” portion where I’ve put multiple domain names. Each of those domains, if their DNS is setup properly, when visited would show the same content.

In apache, this might look something like this:

<VirtualHost *:80>
    DocumentRoot "/usr/share/nginx/html"
    # ...

Hope that helps you get this solved!

Happy Coding,

Andrew DigitalOcean TechOps