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 example.com, my IP address, now what I want is if I put on browser, it will open example.com.


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.

4 answers

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

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

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 http://yourdomain.com/wp-admin/options-general.php 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 / http://example.com/
  • I see, so I don’t need to put example.com as ServerAlias, just ServerName and Redirect. Thanks.

    • @MrWorldWideWeb

      If you put ServerAlias example.com then you would just create a loop, since you’re listening to port 80 and redirecting to http://example.com/

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

        <VirtualHost *:80>
        DocumentRoot /var/www/example.com/public_html

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

Submit an Answer