theisevan
By:
theisevan

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

May 3, 2017 424 views
Networking Ubuntu 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?

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 http://162.243.40.146/wp-admin/options-general.php and edit both WordPress Address (URL) and Site Address (URL) to http://www.evansdetailing.com

  • Exactly right, thank you! Fixed it!
    Something else now, is it possible to make it direct to my site if somebody enters http://evansdetailing.com?

    • 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:
      https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04

      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 ^(.*)$ http://www.evansdetailing.com/$1 [R=301,L]
      </IfModule>
      # END Redirect non-www to www
      
Have another answer? Share your knowledge.