Nginx路由问题与angular 4

Nginx路由问题与angular 4,angular,nginx,nginx-location,Angular,Nginx,Nginx Location,有人能解决Nginx路由问题吗 我的conf文件有以下位置部分 location /pages { alias /path/to/dist/folder index index.html; } 当我点击时,我会按照angular 4路由得到http:example.com/pages/home页面,但当我直接点击http:example.com/pages/home时,它抛出了错误的请求502尝试以下重定向到index.html的路由 index index.ht

有人能解决Nginx路由问题吗 我的conf文件有以下位置部分

  location /pages {
     alias /path/to/dist/folder
     index index.html;
   }

当我点击时,我会按照angular 4路由得到http:example.com/pages/home页面,但当我直接点击http:example.com/pages/home时,它抛出了错误的请求502

尝试以下重定向到
index.html的路由

index index.html;

location / {
  try_files $uri $uri/ /index.html;
}

尝试将以下路由重定向到
index.html

index index.html;

location / {
  try_files $uri $uri/ /index.html;
}

它会将每个请求重定向到
index.html
页面,那么我如何知道用户最初请求了哪个页面?路径保持不变,只是提供的始终是
index.html
。这样,你在应用程序中定义的任何路由都将拾取并处理用户想要导航到的内容。请看一下这个问题,它会将每个请求重定向到
index.html
页面,那么我如何知道用户最初请求了哪个页面?路径保持不变,只有提供的才会始终是
index.html
。这样,你在应用程序中定义的任何路由都将拾取并处理用户想要导航到的内容。你能看看这个问题吗