Wordpress shows on IP and Domain Name after droplet install

January 10, 2016 861 views
WordPress One-Click Install Apps DigitalOcean Apache


I setup a wordpress blog using the 1-click install method, everything works great however my blog shows on both my domain & my IP which isn't good for SEO (duplicate content). Do I need to edit my apache settings in order to redirect the IP to the domain? (if so.. how!)

1 comment
  • From what you are describing that is not actually duplicate content. It is just 2 ways to the same content. You domain resolves to your ip number after the browers or bots checks with a dns server.

1 Answer

like @kely says it isn't duplicate content however it does affect your SEO score once people join your website by IP (wich is most likely not going to happen since its alot more difficult). However you can have the google crawlers to change this IP to the domain name with a 301 redirect and as well have people redirected properly. For this you need to edit your apache VHOST / .htaccess .
Make sure the 000-default.conf has AllowOverride All set for the wordpress directory, if you didn't change this then it should be set on default. Now you want to create a .htaccess file inside the directory of wordpress ( default /var/www/html ) with the following:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^12\.34\.56\.789$
RewriteRule ^(.*)$$1 [L,R=301]

You need to replace the IP and domain to your own setup, once done make sure rewrite module is enabled:

a2enmod rewrite

then restart apache and the rewrite should work:

service apache2 restart

Hope you will figure it out with this, if you still have any questions don't hesistate to ask them.

  • How do you edit the apache VHOST / .htaccess?

    And how do I create the .htaccess file inside the directory of wordpress?

    • This can be done by any text editor, for example nano.

      1. Login to your droplet threw SSH
      2. Go to your website directory, usually this is /var/www/html -->
      cd /var/www/html
      1. Now use nano for example to create the htaccess file:
      nano .htaccess

      And enter the following:

      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTP_HOST} ^12\.34\.56\.789$
      RewriteRule ^(.*)$$1 [L,R=301]

      Now save it and exit it. Then follow the other steps I gave before.

Have another answer? Share your knowledge.