我正在使用nginx编写AngularJS单页面应用程序.
我刚从apache切换到nginx,但我无法使配置文件正常工作.我正在尝试重写所有内容index.html
以让Angular进行路由.
我nginx.conf
的如下:
server { index index.html; location / { expires -1; add_header Pragma "no-cache"; add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"; try_files $uri $uri/ /index.html; } }
是否有可能nginx.conf
像我.htaccess
一样将我的文件放在项目根目录中?
你不想在项目根目录中使用nginx.conf,而且没有必要.此外,您不希望直接更改nginx.conf,而是希望在/ etc/nginx/sites- ln
中使用/ etc/nginx/sites-enabled启用的不同网站的特定文件.
至于配置:
server { root /var/www/mysite/; #or whereever your site files are index index.html; location /{ try_files $uri $uri/ =404; } }
您缺少告诉nginx站点所在位置的根部分.