Replies: 2 comments 1 reply
-
From your code ... <?php
// This is to check if the request is coming from a specific domain
$ref = $_SERVER['HTTP_REFERER'];
$refData = parse_url($ref);
if($refData['host'] !== 'domain') {
// Output string and stop execution
die("Hotlinking not permitted");
}
echo "Executing code here"; Q. When you use the OR condition in the Also you could put the options in an array to allow it to be scalable and cleaner, for example
From the php docs if (in_array($refData['host'], [ 'domain1', 'domain2', 'domain3' ])) { |
Beta Was this translation helpful? Give feedback.
0 replies
-
actually, this was the real code I was trying to use
but when I try to put other code (Multiple domains) it doesn't work this code work when I use single domain |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
<?php
// This is to check if the request is coming from a specific domain
$ref = $_SERVER['HTTP_REFERER'];
$refData = parse_url($ref);
if($refData['host'] !== 'domain') {
// Output string and stop execution
die("Hotlinking not permitted");
}
echo "Executing code here";
?>
Please tell how to add multiple domains in this execution
I also tried- if($refData['host'] != 'website1.com' || $refData['host'] != 'website2.com') {
Beta Was this translation helpful? Give feedback.
All reactions