password protect a single link

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
clarance
Forum Newbie
Posts: 14
Joined: Sun Nov 23, 2008 10:25 am

password protect a single link

Post by clarance »

Hey,

I have played around with different ways of password protecting a video file from a link and I come up empty. the only way I can think of is to have it on a separate page, where that page is password protected?!!!

If anyone know and can help with an attempt to password protect a single link it would be very much appreciated. It doesn't necessarily have to be in php if other methods are there I am all ears.

Thanks

BC
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: password protect a single link

Post by Apollo »

Put a .htaccess file in the same dir as your movie, with this content:

Code: Select all

<files "yourmovie.mkv">
AuthUserFile /some/nonpublic/folder/.htpasswd
AuthName "Sorry, 18+ only!"
AuthType Basic
require valid-user
</files>
And /some/nonpublic/folder/.htpasswd sould be a text file with this line:

Code: Select all

UserName:PasswordHash
where PasswordHash is password, hashed with PHP's crypt function. You can also create a hash online, for example here.
clarance
Forum Newbie
Posts: 14
Joined: Sun Nov 23, 2008 10:25 am

Re: password protect a single link

Post by clarance »

can I do it for all the movies in that directory and not just one?
clarance
Forum Newbie
Posts: 14
Joined: Sun Nov 23, 2008 10:25 am

Re: password protect a single link

Post by clarance »

Thank you for pointing me in the right direction Apollo.

I ended up going with

<MatchFiles>

BC
Post Reply