nextjs重定向slug通配符
我想将REGEX匹配- \ d+
的URL重定向到没有该字符串的URL。 这与最后一个sl一起使用,但对于先前的sl。
这是我的重定向代码:
{
destination: `/my-path/:slug*`,
permanent: true,
source: '/my-path/:slug*(-\\d+)'
}
此URL:http:// localhost/my-path/subdir-one/subdir-two-123
成功地重定向到:http:// localhost/localhost/my-- path/subdir-one/subdir-two
但是,此URL:http://localhost/my-path/subdir-3456/subdir-two-two-123
不成功至:<代码> http:// localhost/my-path/subdir-oon-3456/subdir-two
我以为 *
是匹配整个路径,并假定plo以每条路线应用于每条路线。
我在这里想念什么?
I'd like to redirect URLs that regex match -\d+
to a URL without that string.
This works with the last slug but for the ones prior.
This is my redirect code:
{
destination: `/my-path/:slug*`,
permanent: true,
source: '/my-path/:slug*(-\\d+)'
}
This url: http://localhost/my-path/subdir-one/subdir-two-123
redirects successfully to: http://localhost/my-path/subdir-one/subdir-two
However this url: http://localhost/my-path/subdir-one-3456/subdir-two-123
redirects unsuccessfully to: http://localhost/my-path/subdir-one-3456/subdir-two
I thought the *
was to match the entire path and assumed ???? the regex to be applied on every route.
What am I missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论