Add a subdomain to a URL of my website.

September 18, 2016 646 views
DNS Ubuntu 16.04

I have a Laravel web app running with no issues here in my DO droplet, but i want to add a subdomain (I.e example.reservate.co) to a URL generated by the Laravel app (Is not a server folder). Is that possible? How do i do that.

Thanks!

1 Answer

i want to add a subdomain [..] to a URL generated by the Laravel app (Is not a server folder)

I'm not sure I understand what that means—will the same Laravel app work correctly if it is accessed through the new subdomain (i.e. Sub-Domain Routing)?

If so, all you need to do is add DNS record to map the subdomain to your Droplet's IP address and configure your webserver to serve the same app on the subdomain.

First, add a CNAME record that points to @ which is the root domain (reservate.co):

example CNAME @

Then, edit your nginx configuration adding the new subdomain to your existing server block:

server {
    [...]
    server_name reservate.co www.reservate.co example.reservate.co;
    [...]
}

Finally, restart nginx so that the changes take effect:

sudo service nginx restart
Have another answer? Share your knowledge.