Pagoda nginx server configuration refresh problem Summary 404

We use local vue test and switch pages without any problems. So packed file and upload it to the server, the page can be opened normally, but there will be a refresh page 404, this situation how can we do it?

First analysis of the problem

The reason for this is because in most cases vue in router mode to history mode, page url switch follows the routing switch,
but when refresh browser does not know the parameters of your web page address input is what you want to visit, and did not find file directory you want to access, it will be error 404;

After analyzing the problem we should know how to do it?

A switching mode hash

In direct route into the routing request also, the route mode to hash mode access, but this model has a drawback, it will be back with a # sign,
but we do not want to use this mode, and it seems difficult to see people scratching clear mind, back in the end what is to request it

Second, modify the nginx nginx.conf profile

Add the following code in location. root and index general default.
Unless you index files are not placed in the root directory

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

Third, modify the configuration file pagoda


This modification is not recommended, because there may be intercepted 404

The use of pseudo-static directory

When the domain name can not address error, unified point to the default address

if (!-e $request_filename) {
    rewrite ^/(.*) /index.html last;
    break;
}

Guess you like

Origin www.cnblogs.com/lovecode3000/p/12393168.html