How can I set up NextJS/React routing to fallback to legacy PHP pages when it does not exist in my React app

Viewed 44

I have an old PHP based website that I am slowly converting to React.

I'd like to take the opposite approach and re-create the site in React/NextJS and have it route to a legacy PHP if it can't be found in the React app. This would get my site stack up-to-date and put me in a position to just convert those PHP pages as time permits.

Example.

/about <-- This does not exist in the React app yet, but I do have a PHP page for it.

Goal : The system would see that this page does not exist in the React app and would then pass it off to the PHP router to try and resolve.

Thanks in advance for any insights from you geniuses!

1 Answers

React (on the client) executes after php (on the server). So I think this should work the other way around. Your php router should decide whether to handle something itself or serve the react app.

Related