I want to shut down a website and redirect all pages to the homepage of another, already existing, website.
This is my code in the .htaccess of the website to be shut down:
RedirectMatch 301 ^/ https://www.new-domain.com/
On the target page I want to set a query for visitors of any page of the decommissioned website, which will output an informational text exclusively for those visitors.
Here is the php code I use for this:
if (false !== stripos($_SERVER['HTTP_REFERER'], "old-domain.com")):
echo 'Text, exclusively for visitors coming via a URL of the old site';
else:
// echo '';
endif;
Unfortunately, the query only works as long as I haven't set the redirect in the decommissioned site's .htaccess. It seems that the script does not recognize where the visitors are actually coming from.
How can this be solved?