Let’s say I have two domains: domainA.com and domainB.com. On domainB.com im going to use an iframe to access a PHP file on domainA.com.
Is there a way I can set an if/else statement so that no user can access that PHP file by going to domainA.com/file.php? That file should only load from an iframe on domainB.com.
Multiple ways. One which comes to my mind is using $_SERVER[‘SERVER_NAME’]. If it’s not “domainB.com” then exit execution or do something else. If you have to modify many files edit VHOST and create prepend script which will handle it globally.