How come going to my domain redirects to my ip address?

Posted May 3, 2017 4.1k views
NetworkingUbuntu 16.04

I installed Wordpress onto Ubuntu 16.04, and have connected the name servers to name cheap and everything, which all seems to be done correctly. Whenever I connect to my website, it redirects to the IP address. What should I do to fix this?

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
1 answer

Hi @theisevan

You probably setup WordPress on the IP-address before you added the domain, which means WordPress will save that IP as the root configuration.

You can go to and edit both WordPress Address (URL) and Site Address (URL) to

  • Exactly right, thank you! Fixed it!
    Something else now, is it possible to make it direct to my site if somebody enters

    • Remember to go through each page and update every link which might still statically be set to the IP-address. Haven’t looked through the site, but just saw the Call Now on the front page.

      Next step would be to have a look at Let’s Encrypt, but finish up the site currently - and take a snapshot before making that step, so you always can revert in case of it not working:

      by Erika Heidi
      This tutorial will show you how to set up a free TLS/SSL certificate from Let’s Encrypt on a Ubuntu 16.04 server running Apache as web server. TLS certificates are used within web servers to encrypt the traffic between server and client, providing extra security for users accessing your application.
    • @theisevan Didn’t notice the extra line, since you added it after with an edit.

      You can edit the file called .htaccess in the WordPress root folder and add this to the top of the file:

      # BEGIN Redirect non-www to www
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteRule ^(.*)$$1 [R=301,L]
      # END Redirect non-www to www