简体   繁体   中英

How can you provide an A-name/sub-domain redirect to a Rails app?

I have a rails app with a page at http://mydomain.com/hello .

I would also like to have it mirrored at http://a.usersdomain.com , so that this URL is showing the same app, database, etc.

What I am imagining would be similar to how Tumblr allows you to host a blog at title.tumblr.com and usersdomain.com. Is this possible with a rails app?

You can pretty easily allow users to set up a subdomain on your domain. Just set up a wildcard subdomain with your DNS provider and you can have the rails app do the rest no problem.

So anything.myurl.com will go to your rails app. You can then have a method to get the subdomain and identify the user/site or whatever.

The users having their own domain redirect to the subdomain given can be done as Jason has mentioned in his answer.

You can use a A entry on your DNS management center for the domain. You would point subdomain of a to the IP address of the server that is hosting your rails app. If you do not have a static IP address (like Heroku by default) you can use a CNAME entry and point he subdomain on a to the item listed in the Domains area of the Heroku settings or directly to the current URL like tumblr would. For example on Heroku:

subdomain: a => myapp.herokuapp.com

or tumblr/other hosted url

subdomain a on your domain => title.tumblr.com

or your example:

subdomain a on usersdomain.com => mydomain.com

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM