HTACCESS - prevent files from being downloaded via 'view source'

Joined
Dec 9, 2022
Messages
1
Reaction score
0
Hi there everyone,

I'm trying to create an htaccess file to prevent media files such as mp4/vtt to be downloaded through the browser 'view source' menu, however, I do want the mp4 to be playable in the broswer and the vtt captions to show on the video. Is there a way to accomplish that?
 
Joined
Mar 11, 2022
Messages
226
Reaction score
32
Maybe something like
Code:
RewriteRule \.(vtt|mp4)$ - [F,L]
But:

Can't really say it's impossible, because i really don't know, but i can say that i really doubt it. If a file isn't available from browser (or any other web device), than it's also not available for players. (At least to my understanding)

I guess you need something to protect your files from beeing downloaded but still playable on your site.
I would use AJAX, and a "kind of" own player solution to hide source files.

Short edit:
A while ago i did a similar solution for a client which went out my mind for a sec.

I've converted the mp4 to a binary string and stored them as LONGTEXT. To play them in the player i used a php to read this binary string again with a mp4 header. Plus a hell of a workarround for IPhone preloading and stuff.

At the end my player looked a little like this
Code:
<video>
<source src="myfile.php?id=1" type="video/mp4">
</video>

So i had the opportunity to fully block myfile.php from viewed or opened by a browser.
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top