# 重定向包含Discourse资源名称的旧论坛URL路径

**URL:** <https://meta.discourse.org/t/redirecting-old-forum-urls-when-the-path-contains-the-name-of-a-discourse-resource/349268>\
**Category:** Product Support\
**Tags:** permalinks\
**Created:** [2025 年1 月 27 日 22:31 UTC](https://meta.discourse.org/t/redirecting-old-forum-urls-when-the-path-contains-the-name-of-a-discourse-resource/349268 "2025-01-27T22:31:12Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![hat\_trick](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@hat\_trick](https://meta.discourse.org/u/hat_trick)\
发布日期： [2025 年1 月 27 日 22:31 UTC](https://meta.discourse.org/t/redirecting-old-forum-urls-when-the-path-contains-the-name-of-a-discourse-resource/349268/1 "2025-01-27T22:31:12Z")

</div>

您好，

我旧论坛的网址格式为 /posts/t{topic\_id}-{url\_slug}。

我已经使用 Discourse 的永久链接（Permalink）将旧论坛网址映射到了新的 Discourse 网址。

问题在于，Rails 路由将对旧论坛网址的请求路由到了“posts”资源的一个路由。（我不知道是哪个路由。）

永久链接规范化（Permalink Normalization）是在路由完成后运行的，所以这并不是解决方案。

我认为解决方案是在 config\routes.rb 中添加一个自定义路由，如果网址格式为 /posts/t{topic\_id}-{url\_slug}，则跳过 PostsController 的请求处理。但我对 Rails 路由不够熟悉，无法进行此更改。或者，也许这不是正确的方法？

谢谢。

---

_[View the full topic](https://meta.discourse.org/t/redirecting-old-forum-urls-when-the-path-contains-the-name-of-a-discourse-resource/349268)._
