# Disable hotlinking protection for specific file!

**URL:** <https://www.ruby-forum.com/t/disable-hotlinking-protection-for-specific-file/237764>\
**Category:** NGINX\
**Created:** [November 28, 2013, 9:17am UTC](https://www.ruby-forum.com/t/disable-hotlinking-protection-for-specific-file/237764 "2013-11-28T09:17:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [November 28, 2013, 9:17am UTC](https://www.ruby-forum.com/t/disable-hotlinking-protection-for-specific-file/237764/1 "2013-11-28T09:17:14Z")

</div>

Hello,

```
   The root directory path is /var/www/html/domain and every file

```

within it is hotlink protected for (mp4). Now here’s a file named  
/var/www/html/domain/videos/test.mp4 and i want this file to be  
available  
for public with no hotlinking restriction. Is that possible with nginx ?  
vhost config is given below. Please help me regarding it.

server {  
listen 80;  
server\_name [mydomain.com](http://mydomain.com);  
client\_max\_body\_size 800m;  
limit\_rate 250k;  
access\_log /websites/theos.in/logs/access.log main;

```
    location / {
        root /var/www/html/domain;
        index index.html index.htm index.php;
       autoindex off;

```

}

location ~ -720.(mp4)$ {  
mp4;  
expires 7d;  
limit\_rate 1000k;  
root /var/www/html/domain;  
valid\_referers none blocked [test.com](http://test.com) \*.test.com \*.  
[facebook.com](http://facebook.com) \*.twitter.com;  
if ($invalid\_referer) {  
return 403;  
}  
}  
location ~ -480.(mp4)$ {  
mp4;  
expires 7d;  
limit\_rate 250k;  
root /var/www/html/domain;  
valid\_referers none blocked [test.com](http://test.com) \*.test.com \*.  
[facebook.com](http://facebook.com) \*.twitter.com;  
if ($invalid\_referer) {  
return 403;  
}  
}  
location ~ .(mp4)$ {  
mp4;  
expires 7d;  
root /var/www/html/domain;  
valid\_referers none blocked [test.com](http://test.com) \*.test.com \*.  
[facebook.com](http://facebook.com) \*.twitter.com;  
if ($invalid\_referer) {  
return 403;  
}  
}

Regards.  
Shahzaib

---

<div class="post-metadata">

**Author:** ![shahzaib12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@shahzaib12](https://www.ruby-forum.com/u/shahzaib12)\
**Post date:** [November 28, 2013, 9:56am UTC](https://www.ruby-forum.com/t/disable-hotlinking-protection-for-specific-file/237764/2 "2013-11-28T09:56:24Z")

</div>

Hello!

On Thu, Nov 28, 2013 at 01:16:23PM +0500, shahzaib shahzaib wrote:

> Hello,
> 
> ```
> The root directory path is /var/www/html/domain and every file
> 
> ```
> 
> within it is hotlink protected for (mp4). Now here’s a file named  
> /var/www/html/domain/videos/test.mp4 and i want this file to be available  
> for public with no hotlinking restriction. Is that possible with nginx ?  
> vhost config is given below. Please help me regarding it.

Adding an exact match location will help, e.g.:

```
 location = /test.mp4 {
     # no hotlink protection here
     ...
 }

```

See [http://nginx.org/r/location](http://nginx.org/r/location) for details on location matching.

–  
Maxim D.  
[http://nginx.org/en/donation.html](http://nginx.org/en/donation.html)
