1

I have a domain www.example.com and here is the config of my nginx

    location /data {
    root   /var/www.example.com/html;
    index  index.html;
}

when I hit http://www.example.com/data, I expect the the index.html in folder /var/www.example.com/html will be shown up but it just doesn't.

The location of path is quite simple even without a regex (my requirements is really this simple). What did I do wrong?

Thanks

  • You need to add 127.0.0.1 www.example.com to your hosts file. – Vladimir Kovalchuk Jul 23 '16 at 21:20
1

You need to use alias instead of root. With root, the URI is appended to the path specified, so in your case http://www.example.com/data becomes /var/www/example.com/html/data/data.

With alias /var/www/example.com/html/data, it becomes /var/www/example.com/html/data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.