2011-04-29 44 views
2

我有一对夫妇的路线是这样的:如何301重定向这些路线更改?

match ':category/:brand/:permalink' => 'products#show', :as => :public_product 
    match 'stoves' => 'home#stoves', :as => :stoves 

我把它们改成这样:

match ':category/:brand/:permalink' => 'products#show', :as => :public_product 
    match 'wood_stoves' => 'home#wood_stoves', :as => :stoves 

我改变了标题为stoveswood_stoves的类别记录。

我可以添加路由重定向允许将改变像domain.com/stovesdomain.com/stoves/morso/8140-contemporary分别domain.com/wood_stovesdomain.com/wood_stoves/morso/8140-contemporary,什么通配符?或者我应该把它放在我的apache虚拟主机配置块中?

回答

0

让你route.rb是这样的:

match ':category/:brand/:permalink' => 'products#show', :as => :public_product 
match 'stoves' => 'home#stoves', :as => :old_stoves # anything else except stoves 
match 'wood_stoves' => 'home#wood_stoves', :as => :stoves 

在您的主页控制器:

def stove 
    redirect_to stoves_path(# Use parameters here when a user hits a link like domain.com/stoves or domain.com/stoves/morso/8140-contemporary) 
end 
def wood_stoves 
    # your code here.. 
end 
+0

,我希望有一个单一的解决方案,以她俩都旧居#炉动作和产品#展示行动。 – Preacher 2011-04-29 12:22:30

+0

我正在做这个答案的变体。 – Preacher 2011-05-18 19:27:17

0
match ':category/:brand/:permalink' => 'products#show', :as => :public_product 
match 'stoves' => 'home#stoves', :as => :old_stoves # 
match 'wood_stoves' => 'home#stoves', :as => :stoves 

这就够了,我认为。

如果你是那么讲究改变行动wood_stoves那么我认为你需要做的苏里亚的解决方案的名称