Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Basically, I'm trying to handle nice URLs mapped to actual HTML files on the server.

I have URLs like so:

/posts/nice-blog-post/

That need to return an HTML file on the filesystem like:

/path/to/site/posts/nice-blog-post.html

The location directive I have so far is:

location ^~ /(.*)/$ {
    alias /path/to/site/$1.html;
}

This sort of works, except only the following URL successfully resolves:

domain.com/posts/nice-blog-post

This URL (with trailing slash) returns a 404:

domain.com/posts/nice-blog-post/

So I have two issues:

  1. How do I get the URL with trailing slash resolving correctly?
  2. More importantly, when nginx handles the alias, it doesn't appear to return any response headers. The HTML file is then downloaded as a file rather than being rendered to the browser.
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.