subdomain and domain routing

筅森魡賤 提交于 2019-12-06 12:35:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!