我想改变我现有的‘游戏’路由在routes.rb内,但由于搜索引擎优化,我还需要设置301重定向旧链接。
我的旧路由:
match 'games/:permalink/:id/(:page)' => 'games#show'
新路由:
match 'gierki/:permalink/(:page)' => 'games#show'
下面是我尝试做的重定向:
match 'games/:permalink/:id/(:page)' => redirect {|params| "/gierki/#{params[:permalink]}" + params[:page].nil? ? "" : "/#{params[:page]}" }
上面的重定向不起作用,下面是一个错误:
wrong number of arguments (1 for 2)
发布于 2012-05-30 11:48:19
试着这样做:
match 'games/:permalink/:id/(:page)' => redirect {|params,request| "/gierki/#{params[:permalink]}" + params[:page].nil? ? "" : "/#{params[:page]}" }
看看它能不能用。
https://stackoverflow.com/questions/10815349
复制相似问题