PHP - 引用重定向脚本

I have a tracking link (poly.wtf) . I'm trying to make a php page that check the referred if and to make this condition if the visitor came from my tracking link (poly.wtf) it will redirect him to page X

if the visitor didn't come from my tracking link (anywhere else) or just type the url through the browser it will redirect him to page Y

I'm tried to use this script PHP :

<?php

    $domain = 'poly.wtf';

    $referrer = $_SERVER['HTTP_REFERER'];

     if (preg_match($domain ,$referrer)) {

        header('Location: https://www.google.com/');

     } else {

        header('Location: https://www.yahoo.com/');

    };

?> 

but it doesn't work because for some reason it doesn't capture for me the refer here is example of redirect from poly.wtf link to the PHP page : http://poly.wtf/5d9e31ce-bd7d-4500-bc4e-b7e7f7ddcacc

^^ in this case it should redirect me to google but it doesn't , what do you think is the problem?

You shoul enclose your pattern in some delimiter like:

$domain = '/poly.wtf/';