# Confused by documentation for /alias/

**URL:** <https://www.ruby-forum.com/t/confused-by-documentation-for-alias/210527>\
**Category:** NGINX\
**Created:** [August 10, 2011, 12:15pm UTC](https://www.ruby-forum.com/t/confused-by-documentation-for-alias/210527 "2011-08-10T12:15:35Z")\
**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:** [August 10, 2011, 12:15pm UTC](https://www.ruby-forum.com/t/confused-by-documentation-for-alias/210527/1 "2011-08-10T12:15:35Z")

</div>

Hi

From: [http://wiki.nginx.org/HttpCoreModule](http://wiki.nginx.org/HttpCoreModule)

**BEGIN**  
For example:

location ~ ^/download/(.\*)$ {  
alias /home/website/files/$1;  
}  
The request “/download/book.pdf” will return the file  
“/home/website/files/book.pdf”. Note again that only part of the request  
URI after the location is appended to the path defined by alias.  
_ **END** _

Why doesn’t this return the directory “home/website/files/book.pdf/” ?

Posted at Nginx Forum:

> **[Confused by documentation for /alias/](https://forum.nginx.org/read.php?2,213617,213617#msg-213617)**
>
> Hi From: http://wiki.nginx.org/HttpCoreModule \_\_BEGIN\_\_ For example: location ~ ^/download/(.\*)$ { alias /home/website/files/$1; } The request "/download/book.pdf" will return the file "/home/website/files/book

---

<div class="post-metadata">

**Author:** ![graq](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cc9497/32.png) [@graq](https://www.ruby-forum.com/u/graq)\
**Post date:** [August 10, 2011, 12:19pm UTC](https://www.ruby-forum.com/t/confused-by-documentation-for-alias/210527/2 "2011-08-10T12:19:20Z")

</div>

Hi,

Because of the $ symbol on the location line which marks ‘end of line’.  
Remove the $ symbol and you’ll have book.pdf/ working.

Boyko

---

<div class="post-metadata">

**Author:** ![graq](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cc9497/32.png) [@graq](https://www.ruby-forum.com/u/graq)\
**Post date:** [August 10, 2011, 12:44pm UTC](https://www.ruby-forum.com/t/confused-by-documentation-for-alias/210527/3 "2011-08-10T12:44:07Z")

</div>

I understand the regexp. $1 = book.pdf

So for the specific request in the example, we could write:

location ~ ^/download/(.\*)$ {  
alias /home/website/files/book.pdf;  
}

Is it that the example is unrealistic? Because this config does exactly  
the same thing:  
location /download/ {  
alias /home/website/files/;  
}

I’m struggling to see the difference, and why one would use the regexp.

How about requesting “/download/baz/foo/book.pdf” for the above regexp  
config and this one:  
location ~ ^/download/(.\*)/foo/ {  
alias /home/website/files/$1;  
}

(why would I do this?)

Posted at Nginx Forum:

> **[Re: Confused by documentation for /alias/](https://forum.nginx.org/read.php?2,213617,213622#msg-213622)**
>
> Hi From: http://wiki.nginx.org/HttpCoreModule \_\_BEGIN\_\_ For example: location ~ ^/download/(.\*)$ { alias /home/website/files/$1; } The request "/download/book.pdf" will return the file "/home/website/files/book
