We recently launch subdomain
& custom domain
features in our product: Logdown, a Markdown Blogging Platform.
People keep asking me how to implement, here is how :
(1) Constraint Routing
And in Subdomain
class:
If it doesn't match logdown.com
& www.logdown.com
, then it goes straight to the constraint routing.
(2) Find Current Blog
In PostsController
, we also build a method find_blog
to find @current_blog
.
The sequences will be : subdomain
=> custom domain
=> Not Found
(3) Nginx Setting
The code is very simple, but it tooks me lots of time to figure out...