King Pangilinan
King Pangilinan

Reputation: 597

rails top level domain names and subdomains

I wanna ask on how to implement top level domain using rails.

I am working on a webapp that will allow the user to have a subdomain (by default it will be their username). Right now it is all set and working.

But I want the user to have an option of using their own domain name instead of being a subdomain of my webapp.

Any Ideas, or suggestions? Or a link that points to a page that will help me understand things like this, better.

Basically I want the user to input the "domain name" the he/she bought into my webapp and then my app will take care of that specified domain name.

and also the NAMESERVER if necessary.

Thank You.

Upvotes: 0

Views: 1496

Answers (2)

innonate
innonate

Reputation: 159

Lets say this was a blog site and if traffic went to http://mysubdomain.yourdomain.com you would look up the user by looking up mysubdomain and then looking up the posts for that user.

For a top level domain you'd do something very similar. You'd inspect request.host in the controller (or some other method of Request specific to Rails (I use Merb, so that's my example)) and then find the user based on that, assuming of course request.host didn't match your own app's domain.

As far as how you handle the data goes, I'd probably create a users_domains if users can have more than one domain, or if you have a "blogs" table then just tack a custom_domain column on it.

Upvotes: 0

Ahmish
Ahmish

Reputation: 1151

I'm not sure but it sounds like you're asking more of a DNS question than a Rails question. Maybe you need to set the CNAME of your user domain's DNS record.

Upvotes: 1

Related Questions