Belajar Tidak Identik dengan Buku

Stop hotlinking And Serve alternate content

Using .htaccess, you can disallow hot linking on your server, so those attempting to link to an image, video, music, flash, zip/rar, CSS file on your site, for example, is either blocked (failed request, such as a broken image) or served a different content (ie: an image of an angry man) . Note that mod_rewrite needs to be enabled on your server in order for this aspect of .htaccess to work. Inquire your web host regarding this.

A. Stop hotlinking

To simply stop hotlinking you can add the following to your .htaccess file. Replace mysite.com on line 3 with your own domain name.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com/.*$ [NC]
RewriteRule \.(gif|jpg|jpeg|bmp|zip|rar|mp3|flv|swf|xml|php|png|css|pdf)$ - [F]

B. Serve alternate content

To serve alternate content when hotlinking is detected. You can set up your .htaccess file to actually display different content when hotlinking is attempted. This is more commonly done with images suggesting your displeasure of this activity, such as serving up an “XYZ” image in place of the hotlinked one. Once again, replace mysite.com on lines 3 and 4 with your own domain name.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite.com/.*$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://mysite.com/XYZ.gif [L]

allow with your another sub domain, exp : the sub domain name is subdomain, sub2 and sub3

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite.com/.*$ [NC, OR]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?subdomain.mysite.com/.*$ [NC, OR]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?sub2.mysite.com/.*$ [NC, OR]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?sub3.mysite.com/.*$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://mysite.com/XYZ.gif [L]

Key : Stop hotlinking And Serve alternate content

.htaccess

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Happy Paperless located at Banjarnegara , Jawa Tengah, Indonesia . Reviewed by 28 customers rated: 1 / 5



Rumus-Excel.Com
Kunjungi rumus-excel.com untuk belajar excel. Anda juga dapat menyumbangkan artikelnya ke kami untuk kita publish