That is one way to do it, and it does work. It does require that you have the redirection php file on the same path, and the same file name as the previous file. However, if the previous file had a file name extension other than a php file extension, it won't work (unless you use some additional tricks).
If you are using Apache for your HTTP server, there is an easier solution. You can put the following line in the .htaccess file in the website instead.
Where "/path/" would be the old directory path to the old file from html_public root, and "old_filename.htm" is the name of the old file that no longer exists on the web server. The new target file would be specified with ""http://www.domainname.com/path/new_filename.htm". Including the keyword "permanent" will cause a 301 status code to be returned with the redirection, as opposed to "temporary" which would return a 302 with indicates a temporary URL change.
Are you able to help answer this sponsored question?
Questions asked by members who have earned a lot of community kudos are featured in order to give back and encourage quality replies.