LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 10-18-2003, 08:01 AM   #1
adrianmak
Member
 
Registered: Dec 2002
Posts: 56

Rep: Reputation: 15
how to protect images linking from other website


my site is running VBulletin, I want to protect web images linking from other web sites.

I use mod_rewrite to block all .gif , .jpg and it works.

However in VBB some images are stored in database and those images are generated on the fly, so how do I protect such kind of images ?

e.g. users self upload avatars are stored in database but store in a file on the disk.
i.e.
http://mydomain/avatar.php?userid=22...ine=1042163461

actually that url is an image generated on the fly
 
Old 10-18-2003, 08:12 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Just deny access to avatar.php as well as *.gif or *.jpg unless it is from a local referer.
 
Old 10-18-2003, 08:49 AM   #3
adrianmak
Member
 
Registered: Dec 2002
Posts: 56

Original Poster
Rep: Reputation: 15
how to write this mod_rewrite rule ?
 
Old 10-18-2003, 08:53 AM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
If you look at your existing rules there will be a line that stops your images from getting pulled you can add a new rule the same for avatar.php rather than your jpgs or gifs. If you are unsure then post your current rules.
 
Old 10-18-2003, 09:19 AM   #5
adrianmak
Member
 
Registered: Dec 2002
Posts: 56

Original Poster
Rep: Reputation: 15
here is my existing rules in my .htaccess

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG)$ - [F]


what rule should I add to prevent images generated from avatar.php page ?
 
Old 10-18-2003, 09:35 AM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
You need a rewrite rule like:
RewriteRule .*avatar\.php.* - [F]
 
Old 10-18-2003, 10:53 AM   #7
adrianmak
Member
 
Registered: Dec 2002
Posts: 56

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by david_ross
You need a rewrite rule like:
RewriteRule .*avatar\.php.* - [F]
I added followings in httpd.conf

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://bbs.dmhy.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.dmhy.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://61.152.96.66/.*$ [NC]
RewriteRule .*avatar\.php.* - [F]


but images generated from that php page still can be linked by other web site
 
Old 10-18-2003, 11:27 AM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Well I have created a test environment on my server and it seems to work fine however I can still grab the avatars from your site. Then again I can also get:
http://bbs.dmhy.net/images/newblue/vb_bullet.gif

So maybe you don't have mod_rewrite working at all.

Is it enabled in httpd.conf?
 
Old 10-18-2003, 05:28 PM   #9
adrianmak
Member
 
Registered: Dec 2002
Posts: 56

Original Poster
Rep: Reputation: 15
mod_rewrite should work because i use httpd -l it is compiled in httpd binary

by the way can you grab this image from

http://bbs.dmhy.net/attachment.php?s=&postid=5282545

and why you can grab image from

http://bbs.dmhy.net/images/newblue/vb_bullet.gif

because I don't put a .htaccess under this folder

Last edited by adrianmak; 10-18-2003 at 05:31 PM.
 
Old 10-19-2003, 07:43 AM   #10
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
I can get your logo and the go button - that is all I tried.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password protect a website J_K9 Programming 5 07-07-2005 08:12 AM
Images not loading in website robojerk Linux - Newbie 1 02-17-2005 09:44 AM
How Can I password protect a sub-directory of a hosted website from client PC mark001 Linux - Newbie 18 11-12-2004 02:29 PM
how do I poassword protect a directory on a website, Apache bentman78 Linux - Software 8 06-17-2004 11:12 AM
Want to keep people from linking images. BrianG Linux - Networking 0 01-09-2002 03:13 AM


All times are GMT -5. The time now is 10:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration