2011-04-29 5 views
2

301이 경로 변경을 어떻게 리디렉션합니까?

라는 제목의 카테고리 레코드를 wood_stoves로 변경했습니다.

domain.com/stoves 또는 domain.com/stoves/morso/8140-contemporary과 같이 domain.com/wood_stoves 또는 domain.com/wood_stoves/morso/8140-contemporary으로 바뀌는 와일드 카드를 허용하는 경로 리디렉션을 추가 할 수 있습니까? 아니면 내 아파치 가상 호스트 구성 블록에 넣어해야합니까?

답변

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

나는 고향 # 스토브 액션과 모두를 잡기 위해 하나의 솔루션을 바라고 있어요 products # show action. – Preacher

+0

이 답변의 변형입니다. – Preacher

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에 액션의 이름을 변경하기 때문에 특정 약이 있다면

관련 문제