Last active
August 29, 2015 14:24
-
-
Save janus57/22986007daaff6ed8867 to your computer and use it in GitHub Desktop.
block specific domain against hotlinking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Methode 1 | |
# block specific domains | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
# match example.org/com etc... | |
RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)?example\. [NC] | |
# rewrite to specific file | |
RewriteRule \.(gif|jpg|bmp|jpeg|png)$ http://example.org/bad.jpg [R,NC,L] | |
</IfModule> | |
# Methode 2 | |
# block specific domains | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
# match example.org/com etc... | |
RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)?example\. [NC] | |
# rewrite send HTTP 403 | |
RewriteRule \.(gif|jpg|bmp|jpeg|png)$ - [R,NC,F,L] | |
</IfModule> | |
# Methode 3 | |
# block specific domains | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
# match example.org/com etc... | |
RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)?example\. [NC] | |
# rewrite to specific file | |
RewriteRule \.(gif|jpg|bmp|jpeg|png)$ http://example.org/bann.php [R,NC,L] | |
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('WWW-Authenticate: Basic realm="Le hotlinking c\'est mal !"'); | |
header('HTTP/1.0 401 Unauthorized'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment