![]() |
|
|||||||
| 代码交流 ASP,PHP,JSP等网站源代码下载与交流。 |
|
|
Thread Tools | Display Modes |
|
#1
IP: 61.139.126.97
|
|||
|
|||
|
How do I prevent direct linking of my images? I have had a lot of trouble with people direct linking or hot linking to my images. The biggest problem I have with it is that it costs me so much money in bandwidth charges when people direct link. Bandwidth theft is also a big problem for those with free graphics sites. As long as you own your own domain, or your free host allows you to upload .htaccess files, preventing direct linking is a very simple thing to do. You upload a txt file which you name .htaccess . On the text file, add these lines:
RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com.*$ [NC] RewriteRule \.(gif|jpg)$ - [F] Change nothing in the above lines except for your domain name. Upload the text file, named .htaccess, to your main directory. It's that easy. As long as your host supports mod rewrite, no one will be able to direct link to your .gif or .jpg images!!! You could always replace the direct linked image with another image of your choice such as "direct linking not allowed," "direct linkers are evil," or an advertisement for your site (free advertising hehe). Use this code instead of the above code: RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com.*$ [NC] RewriteRule \.(gif|jpg)$ http://www.yourdomain.com/evil.gif [R,L] Replace your domain name and the file name of the gif you want to show up when someone direct links. Have fun!!! |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|