Hi everybody I have a folder with flv files which are loaded with actionsctrip and flash-vars which are visible in the source code. Does anybody know a .htaccess way to disallow direct downloading or access from another domain? I m having trouble with people who look into my source code and then downlaod swf's and flv's -> and then publish my stuff on their own site or youtube. Thanx and Regerads Martin
Source: altlab.com/htaccess_tutorial.html (p.s replace the ** with tt) Example: Your site url is www.mysite.com. To stop hotlinking of your images from other sites and display a replacement image called hotlink.gif from our server, place this code in your .htaccess file: RewriteEngine On RewriteCond %{HTTP_REFERER} !^h**p://(.+\.)?mysite\.com/ [NC] RewriteCond %{HTTP_REFERER} !^$ RewriteRule .*\.(jpe?g|gif|bmp|png)$ h**p://altlab.com/hotlink.gif [L] The first line of the above code begins the rewrite. The second line matches any requests from your own mysite.com url. The [NC] code means "No Case", meaning match the url regardless of being in upper or lower case letters. The third line means allow empty referrals. The last line matches any files ending with the extension jpeg, jpg, gif, bmp, or png. This is then replaced by the hotlink.gif image from the altlab.com server. You could easily use your own hotlink image by placing an image file in your site's directory and pointing to that file. To stop hotlinking from specific outside domains only, such as myspace.com, blogspot.com and livejournal.com, but allow any other web site to hotlink images: RewriteEngine On RewriteCond %{HTTP_REFERER} ^h**p://(.+\.)?myspace\.com/ [NC,OR] RewriteCond %{HTTP_REFERER} ^h**p://(.+\.)?blogspot\.com/ [NC,OR] RewriteCond %{HTTP_REFERER} ^h**p://(.+\.)?livejournal\.com/ [NC] RewriteRule .*\.(jpe?g|gif|bmp|png)$ h**p://altlab.com/hotlink.gif [L] You can add as many different domains as needed. Each RewriteCond line should end with the [NC,OR] code. NC means to ignore upper and lower case. OR means "Or Next", as in, match this domain or the next line that follows. The last domain listed omits the OR code since you want to stop matching domains after the last RewriteCond line. You can display a 403 Forbidden error code instead of an image. Replace the last line of the previous examples with this line: RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
Thanx. That helped a lot. I'm now doing this: RewriteEngine off RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://www.flashmavi.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://flashmavi.*$ [NC] RewriteRule .*\.(.*jpg)$ /error_403.shtml [R,NC] Code (markup): and it looks like everything works fine. But question: is it ok to start with RewriteEngine off ? Im doing that because the root folder has a mobile redirect and I have the above htaccess file in a folder which is used by both, mobile and non-mobile sites. So I basically want RewriteEngine off RewriteEngine on to reset the rewrite engine. Does that work? Thanx Mavi