Jump to content

URL Restrict (Restrict to Domain PHP)


php4ever

Recommended Posts

I know I found it in these forums but I have looked for hours with no luck.

 

I had a small PHP snippet that I could add to my application that would limit its working to the domain I put in the variable.  I'll be if I can't find it in these forums.  Could someone point it out if you happen to know where it is?

 

I plan to put it in the header of a template and encrypt the header so it can be used to demo it only on a particular URL or domain.  I hope that clarifies which one I was after.

Link to comment
https://forums.phpfreaks.com/topic/62501-url-restrict-restrict-to-domain-php/
Share on other sites

check out the $_SERVER Superglobal array I think one of them refers to the absolute url (and domain) which you can say

<?php
$good_domains = array("me.com","you.net");
if(!in_array($_SERVER['SERVER_NAME'],$good_domains)){
echo "Don't steal my work!";
}
else{
//Display header output
}
?>

I think it might be $_SERVER['SERVER_NAME'];  Try that then on a different server try to fopen it or give me the url and i can try it for you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.