我制作了一个 Angular 应用程序 我的 Angular 应用程序正在 nginx 服务器上运行。当我输入“http: //.8.100.248:30749”时,它显示 nginx 正在运行。(显示默认 index.html)。但是我的应用程序存在于html
具有文件夹名称的文件夹中test
。所以我的应用程序出现在“html -> test-> index.html”中;当我输入“http: //.8.100.248:30749/text/index.html”时,它会显示我的主页。现在我可以在按钮单击示例中从一个页面导航到另一个页面。http:// .8.100.248:30749/test/page_1**。但是当我重新加载这个页面时http://**.8.100.248:30749/test/page_1
nginx 显示我404
页面
所以当我输入 http://**.8.100.248:30749/test/index.html。.我的应用程序在浏览器上运行。但是当我从一个页面路由到另一个页面时,reload
我的页面给了我404
示例 ( http://**.8.100.248:30749/test/page_1
)。
当我重新加载我的角度路由页面时,Nginx 给了我 404。所以我想改变nginx配置
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
你能给我建议一下吗?? 它的行为是因为这个位置没有 index.html 文件 ( http://**.8.100.248:30749/test/page_1
)
见更新
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
新更新
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
try_files $uri $uri/ /index.html;
}