How to bind IP address to domain?

Posted August 2, 2017 11.7k views
LAMP StackUbuntu 16.04

Hi, I can add domain to my dropplet using virtual host, but how can I point my IP address to the domain, let’s say my domain is, my IP address, now what I want is if I put on browser, it will open


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
4 answers

My bad, what I mean is when I open it will stay opening that IP address, but the content is similar to

It seems I work it out, by creating virtual host with that IP address as a name, and as the alias, pointing the same directory as

I have the opposite issue, the droplet IP shows one of the site not the default one ;)

  • Default means an empty one? Try to edit your ipaddress.conf to point new directory and put something there. If you don’t have this you can create it.

  • Hi @Marvix

    If you’ve created a WordPress site, but you started by setting it up using the IP, then you need to modify your URLs in so they are set to you domain instead of the IP.
    If you have a different problem, then please create a new question thread, so we don’t cobble two different questions together.

Hi @MrWorldWideWeb

Create another VirtualHost for your IP and redirect to your domain:

<VirtualHost *:80>
  Redirect permanent /
  • I see, so I don’t need to put as ServerAlias, just ServerName and Redirect. Thanks.

    • @MrWorldWideWeb

      If you put ServerAlias then you would just create a loop, since you’re listening to port 80 and redirecting to

      • How about using document root instead of redirecting it? So on browser it will still showing the IP address but the content from, will it work?

        <VirtualHost *:80>
        DocumentRoot /var/www/

        I tried this and it works, but I don’t know if this is causing problem at backend process or not.