Created
February 2, 2023 02:23
-
-
Save ckaznable/a45586c5846a05a50b31f0d656e47bc7 to your computer and use it in GitHub Desktop.
rewrite old php endpoint to nextjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NextRequest, NextResponse } from "next/server" | |
export function middleware(req: NextRequest) { | |
const url = req.nextUrl | |
// redirect php path | |
if (url.pathname.endsWith(".php")) { | |
url.pathname = url.pathname.replace("index.php", "").replace(".php", "") | |
return NextResponse.rewrite(url) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment