Forum Moderators: phranque

Message Too Old, No Replies

Preventing Hotlinking without editing .htaccess

         

DXL

5:57 am on Jan 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Every time I edit my .htaccess file to disallow hotlinking of audio files only, it affects all of my site's submit forms.

I originally had the audio files in the server's root, I've sinced moved them all into their own folder. Is there a permission setting I can apply through WS_FTP to that folder to allow audio to be accessed through pages on my server, but not hotlinked? Without touching the .htaccess file, anyway.

Nutter

12:44 pm on Jan 6, 2006 (gmt 0)

10+ Year Member



What about having all the audio files in a separate folder and putting the hotlink code in the .htaccess in that folder?

DXL

7:20 pm on Jan 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I wasn't sure if you could do that, I thought the .htaccess file had to be in the root.

jd01

9:04 pm on Jan 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can put the .htaccess file in any directory you would like, and can sometimes speed up your entire site. The only thing you may need to know is if RewriteOptions are set to 'inherit', but only if you need to use some of the rules from a 'higher-level' .htaccess. If you don't need to use anything beyond what is in the directory level file, you should have no problem at all.

You might check out the library for some more information about mod_rewrite basics.

Justin

DXL

8:12 am on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I added an .htaccess file to the folder in question and it seems to be working (so far) without corrupting my Frontpage extensions. I don't understand what you mean by inherit. Here's what the file looks like, does it look okay?

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(wmaŚmp3)$ - [F]

olaf

8:56 am on Jan 12, 2006 (gmt 0)

10+ Year Member



hello,

You know that this is not really save to prevent hotlinking?.

I suggest to use some server side scripting file functions for file downloads.

gr. Olaf

milanmk

5:42 am on Jan 13, 2006 (gmt 0)

10+ Year Member



This should help you out.

RewriteEngine On
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example.com/.*$ [NC]
RewriteRule \.(mp3Śwav)$ - [F]

jdMorgan

6:54 am on Jan 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



DXL,

See RewriteOptions inherit in the Apache mod_rewrite documentation [httpd.apache.org].

Jim