bravo14 Posted March 7, 2017 Share Posted March 7, 2017 (edited) Hi all I have a xml file that builds a league table, but want to provide other sites with access to it for a charge. Is there a way I can check the domain using the xml file has permission to do so? I intended on keeping a key in a database with the URL but how can I get the URL using the xml file? Edited March 7, 2017 by bravo14 Quote Link to comment https://forums.phpfreaks.com/topic/303375-verify-url-using-google-xml-file/ Share on other sites More sharing options...
requinix Posted March 7, 2017 Share Posted March 7, 2017 You can't know who (or what domain) is accessing the file. You can give each site a unique key that they can put in the URL like /path/to/file.xml?key=abcd123then use URL rewriting to turn that into a PHP script RewriteRule ^/?path/to/file\.xml$ path/to/file.php [L]and use PHP to check the key and output the XML if it's allowed. <?php if (!isset($_GET["key"])) { header("403 Forbidden", true, 403); exit; } $key = $_GET["key"]; // validate $key if (/* valid */) { header("Content-Type: application/xml"); header("Content-Length: " . filesize("file.xml")); readfile("file.xml"); } else { header("403 Forbidden", true, 403); exit; } Quote Link to comment https://forums.phpfreaks.com/topic/303375-verify-url-using-google-xml-file/#findComment-1543854 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.