# Files in location

**URL:** <https://www.ruby-forum.com/t/files-in-location/216306>\
**Category:** NGINX\
**Created:** [February 1, 2012, 6:37am UTC](https://www.ruby-forum.com/t/files-in-location/216306 "2012-02-01T06:37:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 1, 2012, 6:37am UTC](https://www.ruby-forum.com/t/files-in-location/216306/1 "2012-02-01T06:37:25Z")

</div>

Hello,

I would like to set up a rule redirecting the root location to another  
address, but to serve files inside this location directly.  
I tried the following:  
location = / {  
rewrite .\* [http://inter.net](http://inter.net) permanent;  
}

[http://intra.net/](http://intra.net/) is redirected as wanted  
[http://intra.net/codes.txt](http://intra.net/codes.txt) is also redirected… but that is not  
intended

## How to avoid that? SHould I try something with an if or a try\_files directive on the $uri variable?

_B. R._

---

<div class="post-metadata">

**Author:** ![B.R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3be4f8/32.png) [@B.R](https://www.ruby-forum.com/u/B.R)\
**Post date:** [February 1, 2012, 7:02am UTC](https://www.ruby-forum.com/t/files-in-location/216306/2 "2012-02-01T07:02:40Z")

</div>

On 1 Fev 2012 05h32 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [1 \<multipart/alternative (7bit)\>]  
> [1.1 \<text/plain; UTF-8 (7bit)\>]  
> Hello,
> 
> I would like to set up a rule redirecting the root location to  
> another address, but to serve files inside this location directly.  
> I tried the following: location = / { rewrite .\* [http://inter.net](http://inter.net)  
> permanent; }

location = / {  
return 301 [http://inter.net](http://inter.net);  
}

location / {  
# serve the files here without a redirect  
}

— appa

---

<div class="post-metadata">

**Author:** ![B.R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3be4f8/32.png) [@B.R](https://www.ruby-forum.com/u/B.R)\
**Post date:** [February 1, 2012, 8:09am UTC](https://www.ruby-forum.com/t/files-in-location/216306/3 "2012-02-01T08:09:24Z")

</div>

Thanks,

It appeared that with some other tests my solution was working…  
Browser cache troubles, it seems.  
Sorry to have bothered you :o\

## Thanks anyway,

_B. R._
