我想将所有流量重定向到我的定价页面通过一个子域到我的主页。我不知道如何在has值中添加通配符。
此语法不起作用:
// next.config.js
module.exports = {
target: 'serverless',
async redirects() {
return [
{
source: '/pricing',
has: [
{
type: 'host',
value: '*.*.*',
},
],
permanent: false,
destination: 'https://example.com/'
}
]
},
}有什么想法吗?
发布于 2021-04-22 18:33:59
Vercel的支持帮助我找到了解决方案。我需要在值中更新我的正则表达式。
// next.config.js
module.exports = {
target: 'serverless',
async redirects() {
return [
{
source: '/pricing',
has: [
{
type: 'host',
value: '.*\\..*\\..*'
},
],
permanent: false,
destination: 'https://example.com/'
}
]
},
}发布于 2021-04-21 10:07:49
如果您想要重定向子域,您需要在该项目上添加重定向。如果你想在/pricing的另一个项目中显示子域的内容(例如pricing.example.com),你可以使用重写。
module.exports = {
async rewrites() {
return [
{
source: '/pricing',
destination: 'https://pricing.example.com'
},
]
},
}https://stackoverflow.com/questions/67184556
复制相似问题