Solve Nginx do page forwarding refresh report 404

Business scene

When using nginx for static resource forwarding, a 404 problem is reported when the page refreshes. As shown below:

The following picture is shown during normal request:
Insert picture description here
When the page is refreshed, or press F5, the following picture will appear:
Insert picture description here

Solution

In the Linux server, modify the nginx configuration file nginx.conf and add the following to the corresponding directory:

try_files $uri $uri/ /index.html last;

As shown in the figure:
My linux path is: /usr/local/nginx, you modify the nginx.conf configuration according to your nginx path.
Insert picture description here
The purpose of adding this line is to request the upper-level path of the current path when the page is refreshed or F5. After configuration, remember to restart nginx.

Guess you like

Origin blog.csdn.net/u010312671/article/details/107779468
Recommended