Home htaccess domain restrict access to file
Reply: 0

htaccess domain restrict access to file

user1179 Published in May 20, 2018, 10:16 am

I need to domain restrict access to a file from a specifc domain AND sub-folder, so that any request coming from any other domain or from the same domain but different sub-folder get a Forbidden error. I have looked at a lot of other questions/answers but can not seem to find what I need.

I have a video file located here: https://example.com/videos/test.mp4

I want to restrict access to that video file so that it can only be accessed by a video tag located in https:// otherdomain .com/sub1/sub2/watch-video/index.html

My index.html file looks like this:

<video controls autoplay>
<source src="https://example.com/videos/test.mp4" type="video/mp4">

I placed the following .htaccess file into https://example.com/videos folder:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^otherdomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^sub1/sub2/watch-video$ [NC]
RewriteRule ^ - [F]

It does not even seem to domain restrict to just otherdomain.com even when I comment out the REQUEST_URI line.

Any ideas what I am doing wrong?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298027 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO