Forum Moderators: phranque

Message Too Old, No Replies

.htaccess anti-leech not working, help please

         

Socceraccess

9:46 pm on Apr 24, 2004 (gmt 0)

10+ Year Member



1)
RewriteEngine On
RewriteCond %{HTTP_REFERER}!^http://([a-z0-9-]+\.)*example.com/ [NC]
RewriteCond %{HTTP_REFERER}!^http://([a-z0-9-]+\.)*64.246.24.58/ [NC]
RewriteRule ^.*$ [example.com...] [L,R]

2)
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^$ [OR]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com/.*$ [NC]
RewriteRule .*\.([zip¦rar¦exe¦gif¦jpg¦jpe?g]+)$ - [NC,F]

3)
RewriteEngine On
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER}!^http://.*example\.com [NC]
RewriteCond %{HTTP_REFERER}!^http://6x\.2xx\.x4\.x8
RewriteRule \.(zip¦exe¦rar)$ - [NC,F]

4)
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.(net¦com) [NC]
RewriteRule \.(zip¦rar¦exe¦gif¦jpe?g)$ - [NC,F]

5)
RewriteEngine On
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER}!^http://.*example\.com [NC]
RewriteRule \.(zip¦exe¦rar)$ - [NC,F]

6)
RewriteEngine On
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.(net¦com) [NC]
RewriteRule \.(zip¦rar¦exe¦gif¦jpe?g)$ - [NC,F]

Additionaly, I have the following in my http.conf

<Directory "/home/directory/www/screenshots">
Options FollowSymLinks
AllowOverride All
</Directory>

LoadModule rewrite_module modules/mod_rewrite.so

Apart from that, my /home/directory/www/screenshots/.htaccess file has the following properties:

-rwxr-xr-x 1 apache apache 164 Apr 24 16:24 .htaccess

I don't remember which of these codes worked, however, I remember that at least some of them blocked images and/or downloads.

However, I've done many configurations to my server since then. The ones that I think could affect referrers are these:

- I have Kiss 2.0 firewall (edited), which forwards any incoming request for port 80 to port81

- Apache runs in port 81

- Squid runs in port 80, working as an http accelerator.

Could anybody help me please? Any ideas?

What if I use this in the httpd.conf file?

<Directory "/home/directory/www/screenshots">
SetEnvIfNoCase Referer "http://www.example.com/" local_ref=1
<FilesMatch ".(gif¦jpg)">
Order Allow,Deny
Allow from env=local_ref
</FilesMatch>
</Directory>

Regards

jdMorgan

3:32 pm on Apr 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Code examples 2 through 6 should block hotlinking under various conditions. It all depends on what you want to accomplish. However, since you didn't describe what you want to do, it's not likely anyone can tell you.

I hope you'll take ownership of your own project, and read some of the threads here [google.com] describing anti-hotlinking methods; Only by understanding mod_rewrite and the various issues surrounding hotlink prevention (especially when it it referrer-based) can you choose the right method for your site. It's up to you to decide what you need to do, implement it, and test it. We can only give general advice or help with very specific code problems.

Jim

Socceraccess

5:57 pm on Apr 27, 2004 (gmt 0)

10+ Year Member



Dear Jdmorgan

In fact I've read numerous posts about mod_rewrite
The frustrating part is that they just don't work on my server.

I think it's because my server is listening to port 81, and squid is listening to port 80. Apart from that, by using Iptables, I redirect incoming requests for port 80 to port 81.

These .htaccess files used to work in the past, however they are just now working at the moment.

I even tried the following in apache:

</home/example/www/images>
Options All
Allow Override All

Then I tried the 6 .htaccess files I described above, and still, nothing worked.

I inserted a direct link to one of my images in another's site forum, and the image always displays.

and I did inserted the .htaccess in the /home/example/www/images/ directory

Any clues?

Regards

jdMorgan

7:02 pm on Apr 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried a simple test to see if mod_rewrite is working at all? -- Something like:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^test_mod_rewrite\.html$ /index.html [R=301,L]

Request the page "test_mod_rewrite.html". If mod_rewrite is working, then you should be redirected to "index.html". The file 'test_mod_rewrite.html" need not exist.

Jim

Socceraccess

9:09 pm on Apr 27, 2004 (gmt 0)

10+ Year Member



Yes

these are the contents of

/home/www/.htaccess

redirect 301 /index.* [socceraccess.com...]

You can test it at www.fifala.com, it forwards to the spanish version of my site.

However when I enter any of the 6 examples I mentioned before at the following directory:

/home/www/images/.htaccess

it doesn't works.
I've tested the Chown and Chmod settings, and they are excactly the same as the ones from the /www/.htaccess file.

I've also doubled checked all the apache settings, and they give /home/www/images even higher privileges than /home/www ones.

I've posted every possible thing that I estimate usefull, do you know what else could I do?

What about my site running on port81 with squid on port 80?

Regards