I help manage a WordPress website for a client. I came across old website PHP pages from a decade ago and was wondering if there was a straightforward way to re-direct all old PHP pages to the current homepage.
Does this require coding or is there a plugin?
Bear with me as I have no experience with PHP.
Thanks!
put this at the start of PHP pages you want to redirect:
<?php
$homeURL = home_url(‘/’);
wp_redirect($homeURL);
Do these old pages have a pattern in the url? For example /old/page.php.
You can do a 301 redirect based on individual URLs or on patterns in your .htaccess file.
Just use Redirection(assuming same domain name) plugin and add the old url slugs then point them to the new page or pages, as you see fit.
If it’s not the same domain, you use htaccess method on old domain root.
https://www.php.net/manual/en/function.header.php