Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
How to Have Site Display Domain Name instead of IP
I’m currently trying to get my site to display its domain name (which I’ll call example.com) rather than the ip address associated with it. I’ve looked at tutorial after tutorial, but I haven’t come across a solution. I’m using Nginx with Wordpress in a docker container running on a digitalocean droplet.
Currently, I have three NS records with hostname set to my domain example.com, and they direct to ns1.digitalocean.com, ns2.digitialocean.com, etc. I can visit my site by typing in example.com, but it then displays the ip address, and I want it to display example.com instead.
I’ve tried the following:
1.) I’ve tried going into my nginx.conf file and changing the server_name variables to my hostname instead of the ip address, but this doesn’t change anything.
2.) I’ve tried navigating to my wordpress wp-config.php file and adding
define('WP_SITEURL', 'http://www.example.com'); define('WP_HOME', 'http://www.example.com');
but this causes a ‘too many redirects’ error. I’ve also tried it without the www, but that also produces a too many redirects error.
What am I doing wrong? Does anyone know how I can get my site to always display the hostname over the ip address? Any help would be appreciated.
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.×