子域和域间路由 [英] subdomain and domain routing

查看:192
本文介绍了子域和域间路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的子域,以表明产品如。 nexusphone.site.com。当用户在该网址我呈现产品的产品/显示视图。用户还可以使用域名的问题如www.nexusphone或nexusphone.com渲染该产品/显示视图。

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或site.com应该呈现主视图这说明了什么我的网站是什么。

www.site.com or site.com should render the home view which explains what my site is about.

我基本上要进入www.site.com或site.com时呈现主视图。在所有其他情况下,我想使产品/显示视图。

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.

在我的路线我有

map.club_root '', :controller => 'products', :action => 'show', :conditions => { :subdomain => /.+/ }
map.root :home

本作品为nexusphone.site.com例子,但不是nexusphone.com。然后,它呈现主视图。

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?

感谢

推荐答案

通过一个小code修改子夫也可以航线基于域名和主机。 的博客文章解释了它的更多细节。

With a small code change subdomain-fu can also route based on domain and host. This blog post explains it in more detail.

这篇关于子域和域间路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆