refactor(guide): redirect old urls to /legacy (#11170)

* refactor(guide): redirect old urls to /legacy

* chore: suggestion

Co-authored-by: Almeida <github@almeidx.dev>

---------

Co-authored-by: Almeida <github@almeidx.dev>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
Naiyar
2025-10-20 19:13:36 +06:00
committed by GitHub
parent 0cc92bd5b0
commit 68835b3ff7

View File

@@ -5,12 +5,19 @@ export function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith('/guide/')) {
const newUrl = request.nextUrl.clone();
newUrl.pathname = newUrl.pathname.replace('/guide/', '/');
return NextResponse.redirect(new URL(newUrl.pathname, request.url));
return NextResponse.redirect(newUrl);
}
return NextResponse.redirect(new URL('/legacy', request.url));
// Redirect old urls to /legacy
if (!request.nextUrl.pathname.startsWith('/legacy') && !request.nextUrl.pathname.startsWith('/voice')) {
const newUrl = request.nextUrl.clone();
newUrl.pathname = `/legacy${newUrl.pathname}`;
return NextResponse.redirect(newUrl);
}
return NextResponse.next();
}
export const config = {
matcher: ['/', '/guide/:path*'],
matcher: ['/((?!_next|api|og|.*\\..*|_static).*)'],
};