Mortgage Calculator - Credit Cards - Loans - Apply for Credit Card - Credit Counseling

PDA

View Full Version : reject a visitor based on the site that referred them - how to?


loopline
Dec 3rd 2007, 11:05 pm
Hello all. I have a question. I would like to know if it is possible to reject or accept a visitor based on who referred them. I am asking for direction as much as I am the answer. I would research it, but I don't even know what this would be called. Here is what I mean.

I have a site. xyz.com and I am getting visitors to the site from this site:

tttttt.com
and
direct browser type in the url traffic

Now I want to allow the users from ttttt.com (secure site) - the traffic is coming from various sub pages, but I want to be able to allow the traffic from the entire domain.

but not allow the direct browser type in traffic.

Does this make sense? How would I do this? I presume it can be done with PHP? Thanks much in advance for your help.

Thank you very much in advance for your help.

MAtt

selling vcc
Dec 3rd 2007, 11:14 pm
You need to know the referrer first : $_SERVER['HTTP_REFERRER']

Then use the function parse_url($_SERVER['HTTP_REFERRER']) to retrieve the domain name and the page path.

Then check the page path with a preg_match() to see what you'll display to the visitor.

I can write a small code for you if you give more details about what you want you script to block/allow

hans
Dec 3rd 2007, 11:16 pm
I do NOT know any PHP solution - there might be one however.
BUT
I belief this could as well be a problem that could be solved using apache configuration directly.
hence if you get NO solution HERE in this thread - have a look at the apache experts section or even mod_rewrite section.

may be all coming from your specific referrer get what they need
all others = rewrite to a default OTHER page OR get an access denied page

you may also meanwhile look thru the apache documents
assuming you have 2.2
http://httpd.apache.org/docs/2.2/

if you get NO reply at all then you may PM nintendo for a mod rewrite solution to your problem as I belief there might be one for a true rewrite expert using apache config features