UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 23rd June 2008, 12:55 PM   #1 (permalink)
iraklis
HPAAAAAAA
 
Join Date: Jan 2007
Location: Thessaloniki, Greece
Posts: 22
subdomains : Restricting access

I have this structure

domain.com
sub1.domain.com
sub2.domain.com
sub3.domain.com


What i`d like to do is allow entrance the the 3 subdomains only for visitors coming from domain.com. If visitors type sub.domain.com in the address bar they should be redirected to www.domain.com.

I have no idea if it is possible and if there is an efficient way of doing this ....
iraklis is offline   Reply With Quote
Old 23rd June 2008, 02:02 PM   #2 (permalink)
TygerTyger
Lumberjack and OK
 
Join Date: Aug 2004
Posts: 823
Code:
if (!empty($_SERVER['REFERER']) && strpos($_SERVER['REFERER'], 'domain.com') === false)
{
exit;
}
Since browsers can fake referrer headers aside from some serious work there's no real way to create restrictions, but that will at least deal with those not deliberately trying to get around it.

Last edited by TygerTyger : 23rd June 2008 at 05:10 PM.
TygerTyger is offline   Reply With Quote
Old 23rd June 2008, 03:44 PM   #3 (permalink)
iraklis
HPAAAAAAA
 
Join Date: Jan 2007
Location: Thessaloniki, Greece
Posts: 22
Thanks
It looks like it will do the job

Just one thing i noticed
the $_server variable didn`t worked as argument to strpos so i had to use another $ref=$_SERVER['REFERER'].

I`m newbee but it doesn`t seem to me "nice"
iraklis is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 04:43 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  UnitedForums  |  SEO by vBSEO 3.0.0
Copyright © 1998-2008 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309