My colleague and I were working on a feature to apply dynamic subdomain name in one of our rails apps. Since a lot of documentation out there only focus on how to host subdomain app by configuring the /etc/hosts file. I reckon I share some insight on how to actually enable dynamic subdomain in your production site using the trusted ol’ Apache web server.
The subdomain-fu gem is such a powerful and convenient gem. From it’s documentation
SubdomainFu provides a modern implementation of subdomain handling in Rails. It takes aspects from account_location, request_routing, and other snippets found around the web and combines them to provide a single, simple solution for subdomain-based route and url management.
Since subdomain-fu has done all the heavy lifting for you. All you have to do once you deployed your subdomain-fu app is include a wildcard asterisk (*) at your DNS level to make your dynamic subdomain work at your production site. However, this approach may not work if you’re using free domain or free DNS.

