如果用户从域移出,则显示PHP页面

I want to realize web page access via previos user URL.

For example, if user open link to my php page from domain *.test.com user can view content on page.

If user open my php page directly, he can't see my page content.

Is it possible to put into php code?

Thanks in advance!

Sure, you can test $_SERVER['HTTP_REFERER'] variable. Here you will see referer of the page

You can parse and use PHP's $_SERVER['HTTP_REFERER'] variable, it contains the referer info taken from browser.

You can find more about $_SERVER variables here

Here's an example:

if(preg_match('/[a-zA-Z\-]+\.test.com/',$_SERVER['HTTP_REFERER']))
{
  echo 'granted';
}

You should replace test.com with your domain. (I haven't tested the code, but it should work)

I answer my question =) I use This code:

    <?php
    $reffer = $_SERVER['HTTP_REFERER'];
    echo "$reffer
";

    if(false !== stripos($reffer, 'test.com')){
      echo "All good
";
    }

else{
echo "Access restricted.";
}
?>

Thanks for the tip Vladimir Gilevich