Restrict direct access for url

kindly we need help to build the following scenario through Cloudflare:-

i have 2 domain xxx.com and yyy.com

i need to allow the users for access the url http://yyy.com/ when redirect from the url http://xxx.com/

and deny the users that make direct access to url http://yyy.com/

Hi @user5754 ,

I don’t think this can be done with Cloudflare Access but I’m not sure

Anyways

//code
$_SESSION['fromMain'] = "true";
header("Location: noaccess.php");
if($_SESSION['fromMain'] == "false"){
   //send them back
   header("Location: foo.php");
}
else{
   //reset the variable
   $_SESSION['fromMain'] = "false";
}

Find more about it here : preventing direct access to a php page, only access if redirected - Stack Overflow

I also recommend to take this type of questions to stack overflow !