• 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} !^https://(.+\.)?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} !^https://(.+\.)?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 ..

Viewing 1 replies (of 1 total)
  • Thread Starter Lenny

    (@lbsources)

    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

Viewing 1 replies (of 1 total)
  • The topic ‘Hotlink Code .. Which .htaccess file?’ is closed to new replies.