Hotlink protection on WP 2.05 (3 posts)

  1. delfim
    Posted 9 years ago #

    I was looking around and couldn’t find a clear hotlink protection tip on WP 2.05. I just want to tell you people about my experience.

    A specific .htaccess file must be put in the wp-content/uploads directory, like this

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yourdomain\.net/ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?subdomain. yourdomain \.net/ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)? subdomain. yourdomain \.net/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule .*\.(jpe?g|gif)$ /angryman.png [L]

    In case you use a sub domain, its URI should be stated.

    The last line defines a specific image (see mine) to be shown instead of the hot linked image. The (jpe?g|gif|bmp|js|mp3) are the file extensions to be access restricted, of course.
    You may wish to show a 403 Forbidden page instead of an image; in this case, just replace the last line, as follows:

    RewriteRule .*\.(jpe?g|gif)$ - [F]

  2. DianeV
    Posted 9 years ago #

    Nice, helpful post; thanks.

  3. Aren Cambre
    Posted 9 years ago #

    This will prevent images from displaying in RSS feeds. How do we get around that?

Topic Closed

This topic has been closed to new replies.

About this Topic