Redirect Lost Posts In WordPress using the Requested URI

Recently I changed my post URLs to include the category before the post slug. While this is a redirect that WordPress can usually handle, I found that redirects coming from my old URL were not routing correct and this snippet fixes that issue.