问题描述
|
我已经创建了一个Facebook应用程序,我希望我的index.PHP文件只能通过facebook应用程序页面看到,而不能通过输入域的直接url看到。现在,该页面可以从两端看到。
例如:-如果转到http://apps.facebook.com/myAppname/,我应该看到index.PHP的内容,但是如果我通过\“ http:// mydomain / \”,则应该为空白页还是应该说不允许。我如何实现相同的逻辑过滤器。
解决方法
您可以使用PHP完成此操作:
<?
$referrer = $_SERVER[\'HTTP_REFERER\'];
if (preg_match(\"http://apps.facebook.com/myAppname/\",$referrer)) {
header(\'Location: http://www.mydomain/index.php\');
} else {
header(\'Location: http://www.mydomain/blank.php\');
};
?>
,也许尝试:
if ($_SERVER[\'HTTP_HOST\'] == \'facebook.com\'){
// Serve page
} else {
// Serve blank
}