A website question
08-01-2010, 10:23 AM, (This post was last modified: 08-01-2010, 10:24 AM by 903.)
#1
A website question
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?
Reply
08-01-2010, 12:31 PM,
#2
RE: A website question
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.
Reply
08-01-2010, 01:20 PM, (This post was last modified: 08-01-2010, 01:36 PM by RichardGv.)
#3
RE: A website question
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.)
Gentoo Linux User (w/ fvwm) / Loyal Firefox User / Owner of a Stupid Old Computer - My PGP Public Key

No man is an island, entire of itself; every man is a piece of the continent, a part of the main; if a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were; any man's death diminishes me, because I am involved in mankind; and therefore never send to know for whom the bell tolls; it tolls for thee.
-- Devotions Upon Emergent Occasions (1624), John Donn
Reply
08-01-2010, 01:27 PM,
#4
RE: A website question
I think it works.But I can't change this server's httpd.conf.
Reply
08-01-2010, 01:39 PM, (This post was last modified: 08-01-2010, 01:42 PM by RichardGv.)
#5
RE: A website question
(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.
Gentoo Linux User (w/ fvwm) / Loyal Firefox User / Owner of a Stupid Old Computer - My PGP Public Key

No man is an island, entire of itself; every man is a piece of the continent, a part of the main; if a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were; any man's death diminishes me, because I am involved in mankind; and therefore never send to know for whom the bell tolls; it tolls for thee.
-- Devotions Upon Emergent Occasions (1624), John Donn
Reply
08-01-2010, 02:21 PM, (This post was last modified: 08-01-2010, 02:22 PM by 903.)
#6
RE: A website question
thanks,I wonder where is the .htaccess.
Reply
08-01-2010, 06:59 PM,
#7
RE: A website question
If it's not in the directory then you need to make the file .htaccess yourself.
With love,
HiddenKnowledge
A.k.a. Yoruichi Shihouin

If you have any questions, feel free to contact me trough email or pm. :)
Reply
08-01-2010, 09:48 PM,
#8
RE: A website question
Thanks.Then which folder should I creat the file?The root folder or every folder I want to protect?
Reply
08-01-2010, 10:00 PM,
#9
RE: A website question
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.
Hi! I'm Zach, and I founded NiftyHost. If you need anything, just PM me! :)
Reply
08-01-2010, 11:06 PM,
#10
RE: A website question
Guess my way was outnumbered :P People like .htaccess more, I suppose.
Reply


Forum Jump: