I am rebuilding an Old Website, all pages ends with .php extension.
Eg: example.com/contactUS.php
example.com/static-article.php
I need to change it to
Eg: example.com/contact-us
example.com/article
I am not just removing .php, changing full URL to more relevant one. so old URL Must be redirected using 301.
so our 404.php should receive all details including all request header , Referer etc.
then 404.php will check if the URL actually existed or not, from an array of deleted pages. If requested URL is present in the array, 404.php will pass the request to new page with 301 status. if the requested URL not present in my array, it will return custom 404 error.
How to do this using Nginx?