0
的routes.rb映射器錯誤:重定向傳統路線呈現耙
Myapp::Application.routes.draw do
root :to => "posts#index"
match "posts/autocomplete_topic_name", :as => "autocomplete_topic_name"
match "/new" => "posts#new", :as => :new
# resources
resources :topics
resources :posts
resources :comments
# static
match "/about" => "pages#about", :as => :about
match "/help" => "pages#help", :as => :help
match "/home" => "home#index", :as => :home
# redirects
match "/tags" => redirect("/topics")
match "/entries" => redirect("/posts")
match "/comments" => redirect("/")
end
截至rake routes
末的錯誤寫着:
tags /tags(.:format) {:to=>#<Proc:[email protected]/home/basicobject/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.6/lib/action_dispatch/routing/mapper.rb:366 (lambda)>}
entries /entries(.:format) {:to=>#<Proc:[email protected]/home/basicobject/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.6/lib/action_dispatch/routing/mapper.rb:366 (lambda)>}
/comments(.:format) {:to=>#<Proc:[email protected]/home/basicobject/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.6/lib/action_dispatch/routing/mapper.rb:366 (lambda)>}
我想一些舊的路徑重定向到新更好的SEO路線。路線如:
/entries/8
需要重定向到/posts/8
等等。
顯示404而不是重定向到根會更好嗎? PS:謝謝你的迴應。我的下一步是爲所有其他路由錯誤創建一個捕獲所有路由。 – BasicObject 2011-06-04 18:15:22
此問題的作者希望保留舊版網址。投擲404的將少到SEO,將重定向到根。你需要做的是用新的URL返回301。當谷歌遇到301的時候,它會更新它的索引。任何其他可以降低您的搜索引擎優化排名給定的內容。 – Stewart 2013-02-05 04:32:56