我有一个configuration在nginx中的网站,configuration如下。 当我访问http://mydomain.com/显示我的默认位置的index.html文件。
但是,当我访问http://mydomain.com/micro-site/时 ,会显示默认的nginx 404页面。 为什么微站点位置configuration被忽略?
server { listen 80; location /micro-site/ { root /var/www/microsite/; index index.html index.htm; } location / { root /var/www/webroot/; index index.html index.htm; } }
错误日志的检查显示:
如果我离开根/位置,那么它正在寻找微型网站位置/ var / www / webroot / microsite。
如果我删除/位置,那么它正在/ etc / nginx / html /
我不确定/ etc / nginx / html /是从哪里来的。
我build议使用alias指令,而不是root的micro-site位置
另外,似乎你使用一些PitFalls (主要是多个相同的index指令)。
所以最后你的设置将如下所示:
server { listen 80; index index.html index.htm; location /micro-site/ { alias /var/www/microsite/; } location / { root /var/www/webroot/; } }
PS:注意额外/在location /micro-site/并检查它是否真的是你所需要的。 也许你会想要删除这个额外的/