ruby-on-railsrubycross-domainweebly

Using rails app as on extension of an existing website


I am trying to use rails app as an extension of my Weebly app.

current domain is hosted by Weebly. I am trying to the following,

I am trying to use the one domain for two different applications(Weebly template website and Rails application)

I thought of two solutions and I don't know if any of them are applicable.

solution

  1. add a subdomain eg. welcomerailsapp.example.com

or

  1. www.example.com/welcomerailsapp

I will be pushing my Rails app to the Heroku server

little guidance would be appreciated

thank you


Solution

  • You can use a CNAME record to do what you want. This would be done at your domain registrar or DNS provider.

    Example:

    Domain: mydomain.com
    
    CNAME www => yourweeblyhost.com (Weebly app server)
    
    CNAME rails => yourrailsapp.com (Heroku server)
    

    www.mydomain.com would then route to your Weebly app, rails.mydomain.com would route to your Rails app.

    This can be done on Weebly via the settings tab under your domain. So all you'd need to do is pick a name for your subdomain, with that as the "name" for the CNAME record and point it to the URL Heroku gives you for your Rails app.

    You can also get more complex with it by using wildcards.

    So if you only wanted one subdomain (www), for example, to route to the Weebly app; you can configure it as such by creating a CNAME for the www subdomain and pointing it to Weebly as noted above. Then, by using a wildcard (usually * on most providers) as the "name" you can tell the internet that [anyotherthing].mydomain.com should route to the Rails app without having to define each subdomain manually.