2011-04-29 48 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那麼我認爲你需要做的蘇里亞的解決方案的名稱