Disable hot linking or direct download of my video

2019-02-15 20:27发布

问题:

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?

回答1:

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.