Page 1 of 1
How do I restrict the users’ URL?
Posted: Thu Feb 20, 2003 11:35 am
by Winter
Hello, everyone.
How do I restrict the users’ URL? For example, only the users whose URL is .edu or .org can link to the page "abc.php" ?
Thanks for the help..
Winter

Posted: Thu Feb 20, 2003 11:55 am
by daven
preg_match() combined with $_SERVER['HTTP_HOST']
Posted: Thu Feb 20, 2003 12:07 pm
by Winter
Thanks for the reply.... but I am new to PHP... so would you please give me a example code?
Thank you so much.
Winter

Posted: Thu Feb 20, 2003 1:17 pm
by daven
preg_match stuff (one of the examples is almost exactly what you want).
http://www.php.net/manual/en/function.preg-match.php
$_SERVER variables.
http://www.php.net/manual/en/reserved.v ... les.server
Out of curiosity, how can you use the URL to restrict access? After all, the script is on your server, so the URL would always be yours. So if your site was
http://www.mysite.com the URL would always be
http://www.mysite.com. You would never see a .edu or .org extension. If you used $_SERVER['HTTP_REFERER'] you could get the page they came from, but that would only work if the link was directly from the other site (ex:
http://www.yoursite.com had a link to
http://www.mysite.com/abc.php).
Posted: Thu Feb 20, 2003 6:26 pm
by McGruff
Apparently, referrer is not very reliable. Think it can be modified or simply might not exist at all - see manual.
Posted: Fri Feb 21, 2003 8:04 am
by daven
True. Which is why I am wondering what Winter is trying to do.