FRIHOST • FORUMS • SEARCH • FAQ • TOS • BLOGS • COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


controlling page access via referalls





ChrisCh
hello all. i didn't really know whether to post this in the HTML forum or the PHP forum so i posted it in here! (feel free to move it Smile)

Well anyway what i am trying to do is this:

I want to block people from typing certain addresses into their address bar and have it load straight away (for example, the URL of my forum). I am wondering if it can be setup (either in a hidden forum setting or a .htaccess setting... or something else:)) so that certain pages can only be viewed when they are accessed by a certain referring URL (for example, a link on my homepage).

If this is possible at all please tell me how! (or post a tutorial link) Smile

thanks Cool
Stubru Freak
You can check the referer http header:

$_SERVER["'HTTP_REFERER"]

But not all browser send this and in fact a browser can lie about this too.
ChrisCh
Stubru Freak wrote:
You can check the referer http header:

$_SERVER["'HTTP_REFERER"]

How would I go about doing that?
Stubru Freak
There are two ways:

1. Check the $_SERVER["'HTTP_REFERER"]:

Code:
<?php
if($_SERVER["'HTTP_REFERER"] != "a page they should come from"){
exit();
}
?>


But some browsers allow to fake this, and others don't send this, so even good visitors won't get the page.

2. Set a cookie on page 1 and get it and destroy it on page 2
ChrisCh
Thanks, I'll give it a go!

Question answered - please lock this topic.
Related topics
Whats it like?
Microsoft makes mobile move
Windows Vista Official Thread
Broadband Internet access via TV cables (cud reach 100mb/sec
HL² engine & its future
My account has been suspended?
new 2gig email service with IMAP > gmail
help me please
Some cPanel and cvsquestions and stuff
Access via FTP seems cut sometimes
[RESOLVED] Hello can Frihost can access via ftp?
private HTML
Managing page access...
how to acces my localhost from another computer
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.