我有一个单页面应用程序,所以我只有一个索引文件。
出于某种原因,每次我直接进入“underpage”时,都会收到错误404。
www.domain.com工作,但不是www.example.com/service。
目前我有这个:
server { listen 80; server_name example.com *.example.com; return 301 https://example.com$request_uri; } server { listen 443 ssl; server_name www.example.com; ssl_certificate /path/to/certificate; ssl_certificate_key /path/to/key; root /var/www/app/app; index index.html; error_page 404 /index.html; }
第一台服务器只是将http请求redirect到https。
我读了一些post,但没有find任何解决scheme。 关于我能做什么的提示?
您的error_page指令不会更改响应代码。 虽然这是可能的(请参阅此文档 ),但try_files指令可能是更好的解决scheme。 例如:
server { ... location / { try_files $uri $uri/ /index.html; } }
详情请参阅此文件 。