WordPress.org

Ready to get started?Download WordPress

Forums

Hotlink Code .. Which .htaccess file? (2 posts)

  1. Lenny
    Member
    Posted 5 years ago #

    Hi..

    So I'm hosting my site with a hosting company, everything works fine. Today I decided to implement the code to prevent hotlinking for images and files (zip,tar).

    As you know you have several accounts under 1 single account with a CPanel host. I want to apply the no hotlinking code to "site 2"

    So the structure is:

    public_html
    public_html/site1
    public_html/site2
    public_html/site3

    There is a .htaccess in all the "site" folders.

    I have the code below..

    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?my-site\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ /files/hotlink.jpg [L]

    Where do I place it?

    public_html/.htaccess

    or

    public_html/site 2/.htaccess

    When I place it in public_html/site 2/.htaccess I get the "server error 500"

    I place it like below..

    RewriteEngine on
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteBase /
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?my-site\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ /files/hotlink.jpg [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    If I put it in the root (public_html) It doesnt work at all.

    Any help at all is appreciated ..

  2. Lenny
    Member
    Posted 5 years ago #

    Figured this out.. Just had to add it to

    public_html/site 2/.htaccess

    Dont know why it worked now.. I think cpanel had something to do with it ..

    LBS

Topic Closed

This topic has been closed to new replies.

About this Topic