nginx解决vue刷新404问题

在配置文件中加入以下配置   

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

如果服务器是apache

在根目录下新建.htaccess文件,然后加入以下配置

<IfModule mod_rewrite.c>

 RewriteEngine On

 RewriteBase /

 RewriteRule ^index\.html$ - [L]

 RewriteCond %{REQUEST_FILENAME} !-f

 RewriteCond %{REQUEST_FILENAME} !-d

 RewriteRule . /index.html [L]

</IfModule>
 

猜你喜欢

转载自blog.csdn.net/cmj8043719242/article/details/106471830