dev #21
@ -19,6 +19,19 @@ export function middleware(request: NextRequest) {
|
||||
request.headers.set("x-site-name", siteName);
|
||||
request.headers.set("x-meta-desc", metaDesc);
|
||||
|
||||
// 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: {
|
||||
// New request headers
|
||||
|
Loading…
x
Reference in New Issue
Block a user