网站A的DNS记录正在将用户转发到网站B。我想做的是:当用户来自网站A时,他应该被重定向到网站B的子页面。我该怎么做?
您可以执行类似的操作
if (isset($_SERVER["HTTP_REFERER"])) { // check if $_SERVER["HTTP_REFERER"] is there or not
if ($_SERVER["HTTP_REFERER"] == 'http://www.example.com/') { // match for domain name
header("Location:http://www.yourBsite.com"); //redirect where you want
}
}
将此代码放在index.php
或首先调用的文件上。