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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.