首页 > 解决方案 > 如何根据用户引用加载脚本

问题描述

我想根据用户引用加载一些 javascript 有什么办法吗?

标签: phpwordpress

解决方案


您可以执行以下操作,它需要引用者并使用 if 语句加载您需要的内容!

$referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/site1.com/",$referrer)) {
      header('Location: http://www.customercare.com/page-site1.html');
} elseif (preg_match("/site2.com/",$referrer)) {
      header('Location: http://www.customercare.com/page-site2.html');
} else {
      header('Location: http://www.customercare.com/home-page.html');
};

推荐阅读