问题
I use the subdomain to indicate the product eg. nexusphone.site.com . When a user types in that url I render the product/show view of that product. Users can also use domainnames eg www.nexusphone or nexusphone.com to render that product/show view.
www.site.com or site.com should render the home view which explains what my site is about.
I basically want to render the home view when www.site.com or site.com is entered. In all other cases I want to render the product/show view.
In my routes I have
map.club_root '', :controller => 'products', :action => 'show', :conditions => { :subdomain => /.+/ }
map.root :home
This works for the nexusphone.site.com example but not for nexusphone.com. Then it renders the home view.
Someone knows how I can solve this?
Thanks
回答1:
maybe the problem is not related with rails...
hope the following link will help
http://www.boutell.com/newfaq/creating/withoutwww.html
cheers
回答2:
With a small code change subdomain-fu can also route based on domain and host. This blog post explains it in more detail.
来源:https://stackoverflow.com/questions/2271524/subdomain-and-domain-routing