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:   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?