I've closed down several sites and have created a script to forward all incoming visitors to the only existing page left - the main page:
$wwwcheck = $_SERVER['HTTP_HOST'];
if(preg_match("/website1/i", $wwwcheck))
{
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: [
website1.net...] );
}
elseif(preg_match("/website2.net/i", $wwwcheck))
{
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: [
website2.net...] );
}
else
{
echo $notfound;
}
with not found having a code to serve up a message. Obviously, I repeat the code several times, one for each closed site.
But subdomain.website1.net or archive.website2.net is not redirecting to the main page. It returns a 404 error.
Can I get round this in PHP?
Thanks
Mike