0

I am serving static html with nginx. I'd like mydomain.com to show index.html in the root folder. For links of the form /pages/page I want them to go to the root directory and pull up page.html from the pages folder.

Here's what I came up with:

location / {
  root /var/www/public_html;
  index  index.html;
  try_files $uri $uri.html http://mysite.com;
} 

However, I get a 404 when I go to my site. It does render index.html if I use try_files /index.html $uri $uri.html http://mysite.com;

1 Answer 1

1

I have to use try_files $uri $uri/index.html $uri.html http://mysite.com;. I thought the index directive was enough..

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.