Multiple Domains for one website

  • Posted January 19, 2015

Hi, I setup my main domain and configured it to be associated with a droplet. Then I setup a second domain and set it up to point to the same ip address. This is all working fine.

What I can’t seem to figure out how to do is for to automatically redirect to I bought the .com address in case people were confused as to the domain, but the one we want to appear in the browser window is



Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

You can do this via a rewrite set up on your web server. Assuming that you are using apache you will need to do the following.

1.) In your virtualhost configuration (if you haven’t set this up specifically this would be the file /etc/apache2/sites-enabled/000-default.conf) change AllowOverride None to AllowOverride All for your main web root.

2.) Next, enable the rewrite module with the commands:

a2enmod rewrite;
service apache2 restart;

3.) Finally, create an .htaccess file in your web root with the following content. This will redirect any requests for or to

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^$ [OR]
  RewriteCond %{HTTP_HOST} ^$
  RewriteRule (.*)$$1 [R=301,L]