来自Friendly_id的重复路由/元标记

时间:2014-04-03 15:11:56

标签: ruby-on-rails friendly-id

Google让我知道我有重复的元标记。这是因为我在设置friendly_id

时有重复的路线
/posts/2
/posts/awesome-post-about-ponys

如何让google / DMZ看不到第一个?

1 个答案:

答案 0 :(得分:1)

我在类似情况下使用的方法是手动捕获非常好的网址并进行重定向

if request.path != post_path(@post)
  redirect_to @post, status: :moved_permanently and return
end