Block direct access to video URL without authentication

0

How can I create an authentication to prevent direct access to any video that is inside a specific folder on the server?

Ex:

Let's say I have a URL: www.domain.com/video/namevideo.mp4

However, I have an application that accesses this URL, but I do not want it to be exposed for anyone to access.

How can I create an authentication to allow only my application to have access to the videos contained in this folder on my server?

    
asked by anonymous 24.07.2018 / 22:23

2 answers

0

You should create a login and password structure and put the access to that specific url with an authentication header in php for example you would put something like this on your page:

<?php session_start(); include("../conexao.php"); if(isset($_SESSION['MSLogin']) and isset($_SESSION['MSSenha']) ) ?>

And create a page to check if this login is actually correct with the following code:

$sql = mysql_query("SELECT * FROM tabela_com_login WHERE login='".$_POST["Login"]."' AND senha='".$_POST["Senha"]."'");
$result = mysql_fetch_array($sql);

if(mysql_num_rows($sql)==1){

Do not forget to create an encryption for the password.

If you still do not know how to do this, try searching for something like login or htacess systems.

    
24.07.2018 / 22:31
0

I believe you can do this without having to use authentication.

Since your non files are in the root folder of your site, you can put all the videos in the / videos / folder and add a in> .htaccess with the following lines:

Order deny,allow
Deny from all

This will cause all direct (web) requests to this page to be blocked, but will not block access to applications that are on the same server, as it is a different type of access.

You can find a more detailed discussion of this link

    
24.07.2018 / 22:57