Forum Moderators: phranque

Message Too Old, No Replies

what's wrong about my htaccess code(SSL)-plaese help

how to prevent direct accesss swf/image file on ssl web

         

ray84514

7:01 am on Nov 6, 2007 (gmt 0)

10+ Year Member



hello,
i want to use htaccess to prevent direct access on my apache server, here is my code

RewriteEngine On
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^https://angle.no-ip.com:8080/.*$ [NC]
RewriteRule ^.*\.(bmp¦tif¦gif¦jpg¦jpeg¦jpe¦png¦swf)$ - [F]

what's wrong about the code? i tested the code, it would block all the image and swf file, i also can't open it.

any one can help me ....thanks

phranque

7:57 am on Nov 6, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, ray84514!
i'm not clear about your problem.
are you saying that all HTTP GETs of image files, whether referred or direct, are refused?
(HTTP response of 403 (FORBIDDEN))

make sure to clear cache between tests...

ray84514

8:46 am on Nov 6, 2007 (gmt 0)

10+ Year Member



thanks for your reply
firstly, i have many flash file on my apache server. since the html source code can see the real path of the flash file, therefore, i want to prevent direct access swf and image file on my server. i am hoping that when access, it maybe show the forbidden or access denied message.

therefore, i want to use the htaccess to protect it, but i tested the code(i had cleared my cache file), it blocked all the swf and image file, i also can not display flash and image on my web, so i want to ask that what's wrong about my htaccess code? or those code can't help me to solve my problem?

any solution can help me?

P.S. sorry for my bad english

phranque

12:39 pm on Nov 6, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



what is the purpose of this line?

RewriteCond %{HTTP_REFERER}!^https://angle.no-ip.com:8080/.*$ [NC]

you should have a RewriteCond such that internal references are allowed.
such as:

RewriteCond %{HTTP_REFERER}!^https?://(www\.)?example\.com [NC]

where example.com is your domain.
note that this regexp:
- would change if subdomains other than "www." should be allowed
- isn't requiring a port specification
- escapes all "." in the url if that matters
- isn't end-anchored
- avoids the usage of the ambiguous, greedy and promiscuous ".*"