• Hello All,

    I’ve been having a problem with other sites linking images and mp3 from my site, this has given me unreliable statistics. Anyhow, I wanted to add some restriction conditions provided by my host to my current word-press htaccess file. Can anyone tell me:

    A.) If this is an uphill battle and I should just let people link away because it can be too complicated for a novice like me.

    B.) Where is the best place to put this htaccess conditions? I have either the option to place it in the root htaccess file or in the 2 folders containing the images (pre and post WordPress 2.0.3,see site structure below)

    C.)Will there be any future problems depending on which directory I add this htaccess info, i.e. back-up issues, etc.?

    D.) Incase I screw up my htacess file, is there a place to find the orginal htaccess file on www.ads-software.com for easy restoring?

    Thanks all in advance,
    Antonio, Editor
    https://www.petitemort.org

    WordPress 2.0.3

    Site structure:

    https://bureaux.petitemort.org/ <- wordpress is installed at root
    https://bureaux.petitemort.org/flotsam <-DIR containing my pre wordpress 2.0.3 images
    https://bureaux.petitemort.org/wp-content/uploads , FIR containing my post WordPress 2.0.3 images uploaded via admin panel.

    Comments I would like to add to the exisiting htaccess file:


    # BEGIN htaccess linking URLs test 08-29-06
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^https?://(www.)?bureaux.petitemort.org/?.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^https?://(www.)?blog.360.yahoo.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^https?://(www.)?blog.myspace.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^https?://(www.)?images.google.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^https?://(www.)?newsgrist.typepad.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^https?://(www.)?petitemort.org/.*$ [NC]
    RewriteRule .(gif|jpg|jpeg|png|mp3|mpg|avi|mov)$ - [F,NC]
    # END htaccess linking URLs test

Viewing 6 replies - 1 through 6 (of 6 total)
  • I put some restrictions to linkage by putting a .htaccess in my uploads directory (where I keep most images/data).

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^https://(www.)?mysite.com/.*$ [NC]
    RewriteRule .(mp3|zip|mpg|jpg|gif)$ - [F]
    </IfModule>

    Are you trying to prevent only certain sites from hot-linking?

    Thread Starter petiteproxy

    (@petiteproxy)

    Actually, my host’s web panel only allows me to create an “allow URL” rule. If I knew how to write a code to “disallow” specific URLS I would do that instead, since it is much simpler disallow certain sites. That way I could just see in my stats who isn’t giving credit or linking back and disallow them.

    Ahhh, I see.

    Suggest you copy .htaccess to a local file on your PC/Mac, under any circumstances, just to have a backup.

    Put these ‘rules’ in a .htaccess only in the folders necessary (not needed above the level, so less ‘clutter’).

    Am pretty sure you won’t have local (to your server) problems with backups/etc. If I’m wrong we should hear about that shortly ;’)

    Uphill Battle? Theoretically: Absolutely ;’) In practice though, I think you’ll find it fairly successful.

    Thread Starter petiteproxy

    (@petiteproxy)

    Thanks Yosemite,

    Putting the htaccess files only in the necessary folders is a good idea. I just figured perhaps a “kill-all” in the root would be easier to track etc..

    So I am assuming now that none of this code (above) will disturb the wordpress code that already exist in my htaccess file:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    & If anyone know the code to “Disallow” certain URl instaed of “Allowing” like the code (above) does, I would appreciate it. Or even a URL pointing to the resource woudl be greatly appreciated.

    Here is what I use:

    # Stop Leechers For Hotlinking Images And Files

    Options +FollowSymLinks

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !(^/robots.txt|/favicon.ico|/sitemap.xml)$
    RewriteCond %{HTTP_REFERER} !^https://(www.)?example.com(/)?.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^https://(www.)?feeds.feedburner.com(/)?.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^https://(www.)?google.com(/)?.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^https://(www.)?bloglines.com(/)?.*$ [NC]
    RewriteRule .*.(torrent|phps|iso|gif|jpe?g|avi|css|doc|mid|mov|mp3|mp4|mpg|pdf|pps|ppt|ra|ram|swf|wav|wma|xml|png|cab|7z|cmd|txt|log|rar|zip|exe|js|ex_|dll|dl_|inf|in_|sys|sy_)$ - [F,NC]

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘forbidding URLs to link to files via htaccess’ is closed to new replies.