【发布时间】:2019-05-12 15:26:06
【问题描述】:
出于 SEO 的原因,我希望我的所有 URL 都以斜线结尾。到目前为止,我有这个功能与nuxt-redirect-module
redirect: [
{
from: '^.*(?<!\/)$',
to: (from, req) => req.url + '/'
}
]
这会检查 url,并在末尾添加一个 / 以防万一。问题是当 url 末尾有参数时。
所以现在,这个重定向
https://example.com/folder 到
https://example.com/folder/(预期行为)
但是使用参数,现在它的工作方式是这样的:
https://example.com/folder?param=true 到
https://example.com/folder?param=true/(它在参数后添加/)
问题
这将是使其重定向的方法,而不是从
https://example.com/folder?param=true 到
https://example.com/folder/?param=true
(所以它会在网址末尾添加/,但在参数之前)
提前致谢!
【问题讨论】: