# Prefixing URL's

**URL:** <https://www.ruby-forum.com/t/prefixing-urls/201014>\
**Category:** NGINX\
**Created:** [December 28, 2010, 6:12am UTC](https://www.ruby-forum.com/t/prefixing-urls/201014 "2010-12-28T06:12:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [December 28, 2010, 6:12am UTC](https://www.ruby-forum.com/t/prefixing-urls/201014/1 "2010-12-28T06:12:56Z")

</div>

I have an app that uses relative URLs

ie: /media/assets/css/style.css

in my server config I have

location /app {

```
 #config stuff here.

```

}

When I go to “/app” from a browser the urls are not prefixed with “/app”  
they stay the same ie: “/media/assets/css/style.css”

But because I mounted the “/app” rather than the root “/” the urls are  
no longer valid.

“/media/assets/css/style.css” should be  
“/app/media/assets/css/style.css”

What options are available to fix this?

Thanks in advance for any guidance.

---

<div class="post-metadata">

**Author:** ![elegant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3ab097/32.png) [@elegant](https://www.ruby-forum.com/u/elegant)\
**Post date:** [December 28, 2010, 12:14pm UTC](https://www.ruby-forum.com/t/prefixing-urls/201014/2 "2010-12-28T12:14:24Z")

</div>

On 28 Dez 2010 05h12 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> When I go to “/app” from a browser the urls are not prefixed with  
> “/app” they stay the same ie: “/media/assets/css/style.css”
> 
> But because I mounted the “/app” rather than the root “/” the urls  
> are no longer valid.
> 
> “/media/assets/css/style.css” should be  
> “/app/media/assets/css/style.css”
> 
> What options are available to fix this?

Try this: [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxHttpCoreModule#alias)

— appa

---

<div class="post-metadata">

**Author:** ![elegant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3ab097/32.png) [@elegant](https://www.ruby-forum.com/u/elegant)\
**Post date:** [December 28, 2010, 2:54pm UTC](https://www.ruby-forum.com/t/prefixing-urls/201014/3 "2010-12-28T14:54:26Z")

</div>

Hello!

On Tue, Dec 28, 2010 at 12:12:49AM -0500, David J. wrote:

> When I go to “/app” from a browser the urls are not prefixed with  
> “/app” they stay the same ie: “/media/assets/css/style.css”
> 
> But because I mounted the “/app” rather than the root “/” the urls  
> are no longer valid.
> 
> “/media/assets/css/style.css” should be “/app/media/assets/css/style.css”
> 
> What options are available to fix this?

By saying “not prefixed” you mean nginx doesn’t replace urls in  
your app’s response? It is not supposed to do so.

Some trivial things may be resolved with sub filter module[1], more  
complex cases generally require fixing application.

[1] [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpSubModule)

Maxim D.

---

<div class="post-metadata">

**Author:** ![elegant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3ab097/32.png) [@elegant](https://www.ruby-forum.com/u/elegant)\
**Post date:** [December 28, 2010, 3:05pm UTC](https://www.ruby-forum.com/t/prefixing-urls/201014/4 "2010-12-28T15:05:45Z")

</div>

Hi,

On 28/12/2010 07:12, David J. wrote:

> I have an app that uses relative URLs
> 
> ie: /media/assets/css/style.css  
> This is not a relative URL, it’s an absolute URL from the base of the  
> current host.

You need to either use

media/assets/css/style.css

or

/app/media/assets/css/style.css

Marcus.
