Forum Moderators: phranque

Message Too Old, No Replies

.htacess file probs

         

lcampers

7:50 pm on Nov 11, 2005 (gmt 0)

10+ Year Member



so on the index to my website i've uploaded a notepad file called ".htaccess.txt"

in the file it just has this text:

SetEnvIf Referer mysitesname\.com ALLOW
order allow,deny
allow from env=ALLOW
deny from all

yet i'm still seeing a lot of hotlinking, particularly from online forums

am i doing something incorrectly?

thanks!

jdMorgan

8:06 pm on Nov 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



1) The filename on the server is almost always ".htaccess" -- no more, no less. If you administrate the server, you can change the filename if necessary (for example, if you run Apache on a Windows machine), but this is not the usual case.

2) Your code, if it worked, would stop not only 'hotlinking' but *all linking.* The referrer denial makes no distinction between people linking to your media (hotlinking) and people linking to your pages.

3) And it would stop linking for all domains, including your own, because the Order [httpd.apache.org] directive is incorrect.

For a start, I'd suggest:


<FilesMatch "\.(gif¦jpg)$">
SetEnvIf Referer mysitesname\.com ALLOW
SetEnvIf Referer ^$ ALLOW
# Include the next line if you use custom 403 pages:
SetEnvIf Request_URI ^/path_to_your_custom_403_page\.html$ ALLOW
Order Deny,Allow
Allow from env=ALLOW
Deny from all
</FilesMatch>

Change the broken pipe "¦" character in the code above to a solid pipe before use; Posting on this forum modifies that character.

Note that this also allows blank referrers, so that people behind corporate or ISP cahcing proxies (e.g. all AOL users) won't be blocked.

Jim

lcampers

11:24 pm on Nov 11, 2005 (gmt 0)

10+ Year Member



thanks jim

I've saved and uploaded the ".htaccess" file without the extension (the icon changed as well, i assume this is normal), replaced the broken pipe with a solid one and also deleted the lines about the 403 pages, mostly because I assume if I don't know what they are then I probably don't have them no?

Now It's uploaded to my root directory and we shall see from there?

I am still seeing a hotlinked picture showing on a forum site though.

Thanks again,

-L

jdMorgan

11:45 pm on Nov 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Flush your browser cache (Temporary internet files) after *any* change to access-control code.

Jim

lcampers

5:56 pm on Nov 13, 2005 (gmt 0)

10+ Year Member



thanks again jim, but it still wasn't working

i put this code in my .htaccess, but it blocked the entire site from the internet!

RewriteEngine On
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mysite\.com/ [NC
RewriteCond %{HTTP_REFERER}!^$
RewriteRule \.(jpe?g¦gif¦bmp¦png)$ - [F]

is there anyway to tweak this to block images?

thank you

jdMorgan

10:10 pm on Nov 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are missing a closing square bracket on the first RewriteCond line. Other than that, there is nothing wrong with the code you posted. If you still have trouble, please be very specific and tell us how you tested, what URLs you tested, and exactly what error indications you see. Also post the relevant contents of your server error log.

Jim

lcampers

4:31 am on Nov 14, 2005 (gmt 0)

10+ Year Member



Thanks very much again, esp. for your patience

ok... i posted the code in a notepad, saved it as a .txt file, uploaded it to my site, changed it to be only .htacess

i cleared the caches from my browswers and everything

yet... my picture is still hotlinked on the following forum page (can i post the link?)... they do give the site a link also, which i appreciate, but not all of the unwanted traffic

<Sorry, no example URLs>

[edited by: tedster at 10:23 am (utc) on Nov. 14, 2005]

jdMorgan

1:53 pm on Nov 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> changed it to be only .htacess

Did you mean ".htaccess"? It won't work if named ".htacess".

Jim

lcampers

4:24 pm on Nov 14, 2005 (gmt 0)

10+ Year Member



sorry, yes .htaccess