Skip to content

Instantly share code, notes, and snippets.

@codepo8
Last active June 29, 2021 16:58
Show Gist options
  • Save codepo8/8557863 to your computer and use it in GitHub Desktop.
Save codepo8/8557863 to your computer and use it in GitHub Desktop.
Simple redirect of hotlinked images in .htaccess
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
# allowed domains, add as needed
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?christianheilmann.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?wait-till-i.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mozilla.org [NC]
# search engines and social sites and stuff
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteCond %{HTTP_REFERER} !search\/cache [NC]
RewriteCond %{HTTP_REFERER} !cache [NC]
RewriteCond %{HTTP_REFERER} !bing\. [NC]
RewriteCond %{HTTP_REFERER} !fbcdn\. [NC]
RewriteCond %{HTTP_REFERER} !facebook\. [NC]
RewriteCond %{HTTP_REFERER} !pinterest\. [NC]
RewriteCond %{HTTP_REFERER} !feedly\. [NC]
RewriteCond %{HTTP_REFERER} !pulse\. [NC]
RewriteCond %{HTTP_REFERER} !aol\. [NC]
RewriteCond %{HTTP_REFERER} !t\. [NC]
# image to redirect to
RewriteRule \.(jpg|jpeg|png|gif)$ http://i.imgur.com/wXVywfE.jpg [NC,R,L]
@PauloBoaventura
Copy link

Hello, I would like to know if this is useful in the current times and can I use it in .htaccess from any platform?
Sorry, I'm newbie ...
Can you help me???

BR ==
olá, gostaria de saber se isso serve nos tempos atuais e posso usar no .htaccess de qualquer plataforma?
Desculpe sou novato...
Pode me ajudar???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment