Question

How can I add subdomain as alias in digitalocean?

Posted October 21, 2021 104 views
WordPressDigitalOceanDNSDigitalOcean Droplets

I have droplet with wordpress on DO. Also I have cloudfare A type record as example.com (ip is droplet ip). It working well but I want adding new alias as reviews.example.com. If user enter reviews.example.com he get my WP site as hi enter example.com. I added in cloudflare A record for reviews.example.com (ip is droplet ip) and added in DO networks new A record for reviews.example.com. But reviews.example.com is redirected to example.com. What I am doing wrong?

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

Hello,

There are a few things that I could suggest here:

  • If you are building a separate website for your reviews subdomain, I would recommend creating a new Apache Virtual Host so that the reviews subdomain could have its own document root and Apache configuration. You can follow the steps on how to do that here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04

  • In case that you want the reviews subdomain to share the same files as your main website, for example, you would need to do that if you are building a WordPress Multisite. Then you need to edit the Apache virtual host for your main site and under the ServerAlias list add your reviews subdomain.

Note that in both cases after making the change to your Apache configuration, you would need to run a config test with:

sudo apachectl -t

And only if you get Syntax OK then start Apache.

Hope that this helps!
Regards,
Bobby

by Lisa Tagliaferri
This tutorial will guide you through setting up multiple domains and websites using Apache virtual hosts on an Ubuntu 18.04 server. During this process, you’ll learn how to serve different content to different visitors depending on which domains they are requesting.