Friends Only Site Access

rockee

New Member
Messages
120
Reaction score
0
Points
0
Here is a nice little .htaccess helper that will allow only your known friends to access a particular folder on your web site without the need to provide an authentication method like a username and password combination, which can be a hassle to set up just for a couple of your best friends to access some special files you want them to see or to download.

All your friend needs to do is provide you with their IP address, which you more than likely know already.

This is not suitable for your friends who may have a dynamic IP provided by their ISP - a dynamic IP is one that changes every time you connect to the Internet via your Internet Service Provider (ISP).


1. Make a new folder under your web root public_html folder and name it what you like and place the files you want only your friends to access in this new folder.
(You could even create a sub-domain via cPanel for this purpose if you prefer, but remember they are limited in quantity on free hosting).
Make sure you also add an index.html or an index.php file to this folder or if you prefer just a file listing then omit adding an index file.

2. Create a .htaccess file in your cPanel File Manager(Legacy) or via your ftp client and add these lines:

order allow,deny
allow from 111.222.333.444
<- substitute here your friend's IP
deny from all

Or if you wish to add multiple known friends and their IPs, so only they have access to this special folder, do this:

order allow,deny
allow from 111.222.333.001
<- substitute here your friend 1's IP
allow from 111.222.333.002 <- substitute here your friend 2's IP
allow from 111.222.333.003 <- substitute here your friend 3's IP
deny from all

3. Save the file.
Now all you need to do is tell your friends the URI of this special folder.
For example:
http://you.x10hosting.com/friendsfolder/
or
http://yoursite.tld/friendsfolder



If you fall out with a friend you have given this special access to, then all you need do is delete that ex-friends IP from the .htaccess file and voilà, access is denied - conversely if you find a new friend and want to add their IP, then edit the .htaccess file again and simply add their IP to the list.
Job done!


Happy file and picture sharing. :)

Regards,
Rocky
 

tittat

Active Member
Messages
2,478
Reaction score
1
Points
38
but the problem is most of us have dynamic ip.
Does this stuff work with widcard characters,so that we can try to implement it for dynamic ip's.
 

rockee

New Member
Messages
120
Reaction score
0
Points
0
Yes wild card IP ranges not characters are possible, here's how to cover a range of IP addresses from a particular ISP.
order allow,deny
allow from 111.222.333 <- substitute here your friend's Dynamic IP range
deny from all


or even more allowed IPs in this ISP's dynamic range.
order allow,deny
allow from 111.222 <- substitute here your friend's Dynamic IP range
deny from all


Regards,
Rocky
 
Top