The reason the rewrite doesn’t work is because it’s always the original request’s URI which is sent as REQUEST_URI
to the PHP app, and that’s what modern PHP apps use for routing. The php_fastcgi
directive will rewrite URLs it doesn’t recognize as being file it can serve to index.php
– the rewritten URI is used as the PHP script to invoke. You would have to override env REQUEST_URI
being passed to PHP, which is pretty hacky, I don’t recommend that.
You might want to consider using a redir
instead, especially if this POST
is performed by a browser (they’ll follow a redirect for a POST
). Make sure to use status code 308
for the redirect so that it preserves the HTTP method correctly.
Are you sure you can’t keep the route in your app itself until it no longer gets hits? You can do an internal re-handling on that route, and include a small bit of logging to keep tabs on whether it’s still getting hits, and after it no longer seems used anywhere you can then remove it.