fix: middleware redirect /about/<slug>/
This commit is contained in:
parent
d7724c4423
commit
ca697cf6f6
@ -19,12 +19,18 @@ export function middleware(request: NextRequest) {
|
||||
request.headers.set("x-site-name", siteName);
|
||||
request.headers.set("x-meta-desc", metaDesc);
|
||||
|
||||
// redirect for some path
|
||||
// redirect for /blog/<slug>/ path
|
||||
const blogPathRegex = /^\/blog\/([^\/]+)(\/[^\/]*)*\/?$/;
|
||||
if (blogPathRegex.test(path)) {
|
||||
const newBlogPath = path.replace(/^\/blog/, "") || "/";
|
||||
return NextResponse.redirect(`${mainUrl}${newBlogPath}`, 301);
|
||||
}
|
||||
// redirect for /about/<slug>/ path
|
||||
const aboutPathRegex = /^\/about\/([^\/]+)(\/[^\/]*)*\/?$/;
|
||||
if (aboutPathRegex.test(path)) {
|
||||
const newAboutPath = path.replace(/^\/about/, "") || "/";
|
||||
return NextResponse.redirect(`${mainUrl}${newAboutPath}`, 301);
|
||||
}
|
||||
|
||||
return NextResponse.next({
|
||||
request: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user