I want to disbale hot linking of FLV
and MP4
videos hosted on my server, except when the videos are displayed from a page which its URL starts with :
http://www.mywebsite.com/index.php?main_page=videos_page&
What are the apache configurations that I have to add to my .htaccess file?
Asked
Active
Viewed 3,721 times
1

KarimMesallam
- 290
- 8
- 19
-
1This is near duplicate of [Apache .htaccess hotlinking redirect](http://stackoverflow.com/q/1126552/331508) and several others. – Brock Adams Jun 17 '11 at 07:03
1 Answers
2
To disable hot-linking and replace the content with a generic site logo fo sorts to direct people back to your site rather then the image, add this to the .htaccess folde rin the root of your site:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite\.com/ [NC]
RewriteCond %{REQUEST_URI} !hotlink\.(gif|png\SOME FILETYPES NOT TO HOTLINK) [NC]
RewriteCond %{REQUEST_URI} !^/index.php?main_page=videos_page&
RewriteRule .*\.(gif|jpg|png)$ http://www.mywebsite.org/generic/imagetoreplace.png [NC]
Remember, .htaccess is hidden, so make sure 'show hidden files' it turned on in yoru ftp client.

alt
- 13,357
- 19
- 80
- 120
-
-
Maybe you could elaborate. Your questional was disabling hotlinking on videos. Just change gif|png to mon|avi|mp4|flv... etc. Then just add a rewrite condition for that url. Easy. What am I not getting here? – alt Jun 17 '11 at 15:33
-
I said in my question "except when the videos are displayed from a page which its URL starts with : http://www.mywebsite.com/index.php?main_page=videos_page&. you didn't mention anything answering that. – KarimMesallam Jun 17 '11 at 15:40
-