How to redirect with new headers back to the same page?

User goes to page /foo, we check if this page is protected, if it is, we rewrite the page to something else using middleware, now this identical page has a password form. The goal is to authenticate the password, and if its correct, redirect them back to the original page with headers pretty much allowing the user to skip the rewrite in the middleware and view the protected page. Is this possible?