NiftyHost Forums (Archive)

Full Version: A website question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
If I put some pictures on my website in this server.How can I do with PHP to make these pictures display normally on my page but display nothing or display a warning picture on other website?
I believe what you're looking for is "HotLink Protection". It can be found at your cPanel, it's called "HotLink Protection". Turn it on, and make sure it protects your domains.
Hotlink protection does not actually need PHP to work. The most common technique is to judge whether the user is accessing from a correct source by checking the "Referrer" HTTP header. This can be achieved easily by Apache itself:
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\\.)?yoursite\\.com [NC]
RewriteRule \\.(gif|jpe?g)$ /images/hotlink.$1 [L]
(These code are supposed to be added to .htaccess or httpd.conf. The respective hotlink error images need to put on your server. The code came from this article: http://www.dagondesign.com/articles/hotl...-htaccess/ )
Of course, using cPanel hotlink protection is easier, if less customizable. (And I believe cPanel actually do it by writing a .htaccess.)
I think it works.But I can't change this server's httpd.conf.
(08-01-2010, 01:27 PM)903 Wrote: [ -> ]I think it works.But I can't change this server's httpd.conf.

Well, you can almost never change the httpd.conf of the server of a shared hosting, and you should not, either. Just add them to .htaccess . (But make sure you have read the notes below the code.) .htaccess does have some significant differences and limitations in comparison to httpd.conf, but they have the same syntax, and when doing some simple jobs, they are essentially the same.
thanks,I wonder where is the .htaccess.
If it's not in the directory then you need to make the file .htaccess yourself.
Thanks.Then which folder should I creat the file?The root folder or every folder I want to protect?
The lowest-level to protect. If I had /bob/joe/jane.png and /bob/doug/jeff.png and wanted to protect both, i'd put the .htacess in /bob/.htaccess. If I wanted /curly/hair/clown.png to be protected as well, put it in /.htaccess.
Guess my way was outnumbered :P People like .htaccess more, I suppose.
Pages: 1 2