我有几条这样的路线:
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
我将标题为stoves
的类别记录更改为wood_stoves
。
我可以添加路由重定向,允许分别将domain.com/stoves
或domain.com/stoves/morso/8140-contemporary
更改为domain.com/wood_stoves
或domain.com/wood_stoves/morso/8140-contemporary
的通配符吗?或者我应该把它放在我的apache virtualhost配置块中?
答案 0 :(得分: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