User account menu

  • Log in
BXTra.net

Breadcrumb

  • Home
  • Articles
  • [HOW-TO] Prevent Hotlink in Drupal 6 + Nginx

[HOW-TO] Prevent Hotlink in Drupal 6 + Nginx

By BXTra | 12:52 AM PST, Tue February 15, 2011
Drupal
Nginx

I have searched around how to prevent hotlink in Drupal when use with Nginx. A lot of website saying the same what to do. However, I have tried all of them but not even one of them that work. That was strange. I started to try more until this... I found the only method that work for me. Oh... one more thing... don't put them under "location" rule or it won't work. That took me half an hour to figure it out :(

Nginx Vhost configuration file - working config to protect hotlink

valid_referers server_names none blocked *.domainname.com;
     if ($invalid_referer) { 	
          rewrite ^/files.*\.(gif|jpg|jpeg|png|bmp)$ http://www.domainname.com/nohotlink.gif last;
     }

That's it. The code above will redirect all invalid domains that is access files directory into an image specified.

Source :
- http://wiki.nginx.org/NginxHttpRefererModule

About text formats
  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

  • Will the router get the Openvpn as a client option?
    6 years ago
  • cancellation
    6 years 1 month ago
  • Router ASUS RT-N12 D1 tomatoes passwort falsch
    7 years 8 months ago
  • WPS button = 30/30/30 hard reset button
    7 years 9 months ago
  • Save my day!
    8 years 3 months ago
  • How to
    8 years 6 months ago
  • Can i still access my modem (the one with the ISP provided)?
    8 years 6 months ago
  • A saving step!
    8 years 10 months ago
  • Problem with Asus n12e-c1
    8 years 11 months ago
  • don't use Hostgator
    9 years 2 months ago

© 2007 - 2023 BXTra.net. All Rights Reserved. 
Certain other content, photos and artwork displayed on BXTra.net are protected by copyright and are the property of their respective owners.

Privacy Policy