How do I restrict the users’ URL?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Winter
Forum Newbie
Posts: 15
Joined: Fri Feb 07, 2003 12:29 pm
Location: Texas
Contact:

How do I restrict the users’ URL?

Post 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 :oops:
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

preg_match() combined with $_SERVER['HTTP_HOST']
Winter
Forum Newbie
Posts: 15
Joined: Fri Feb 07, 2003 12:29 pm
Location: Texas
Contact:

Post 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 :oops:
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post 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).
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Apparently, referrer is not very reliable. Think it can be modified or simply might not exist at all - see manual.
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

True. Which is why I am wondering what Winter is trying to do.
Post Reply