So I've moved my website from site.com to sub.site.com. I have also moved the booking system.
Is it possible for me to have PHP code on index.php on site.com to check if the user wanted site.com/unbook.php to automatically redirect them to sub.site.com/unbook.php
The optimal thing would be some kind of "redirect everything if there is anything in the url other than site.com"
Something like
$urlafter = explode("site.com", $url);
if (strlen ($urlafter[1]) > 0 ) {
header("Location: sub.site.com".$urlafter[1]);
exit();
}
Or would it be better using something like $_SERVER[REQUEST_URI]
or even .htaccess
-- EDIT --
Non duplicate because they only show .htaccess answers, I'd prefer PHP