Search code examples
videojoomlamp4

how to make an .mp4 file inaccessible on the public side


I'm writing to ask you for help. I manage a video site, my interest is to make an .mp4 file private, let me explain better.

Inside my web space there are videos that are managed with yendif video player since I use Joomla as CMs. Up to this point the problem does not arise because the user who needs to see the video must be logged in to do so.

The problem arises instead if the customer knows the direct link to the mp4 file for example (www.miosito.com/folder/folder/video.mp4) in this case the user can download it.

I tried two different solutions.

  1. Modify the group permissions by removing the check with filezilla for reading. By doing so, the registered user cannot see the film.
  2. Privacy directory present in cpanel, but I excluded this because you need to set a user and password to see the videos.

Turning to you, is there a way to make the video not accessible on the public side and at the same time used for viewing by the logged in user?

Thanks in advance.


Solution

  • you can use htaccess :

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

    Create a hetaccess file in the ROOT_PATH/folder/folder directory next to your videos and put the above code in it.