I want to make nginx serve an HTML file for /foobar/. I tried 2 configurations and neither worked.
In Apache you do it like this:
AliasMatch ^/foobar/$ /home/admin/foobar/foobar.html
My first attempt:
location /foobar/ {
alias /home/admin/foobar/foobar.html;
}
Going to /foobar/ shows a 500 error page. The error log says:
2011/08/05 04:12:35 [alert] 32465#0: *1 "/home/admin/foobar/foobar.htmlindex.html" is not a directory, ...
This is weird. Why did it append "index.html" to the end of the file path?
My next attempt:
location ~ ^/foobar$ {
alias /home/admin/foobar/foobar.html;
}
Going to /foobar makes my browser download the file. This is weird. Why did that happen?
I was able to get it to work with this:
location /foobar.html {
alias /home/admin/foobar/foobar.html;
}
This works, but it has the wrong URL. It has /foobar.html instead of /foobar/.
How do I do this?