欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

vue在history的路由模式下,刷新后界面报404

程序员文章站 2022-03-21 08:04:08
需要配置下nginx,位置在/conf/vhosts/*.conf,将当前目录下的所有conf都修改一下最好server { listen 80; server_name agwenbi.vip; root "C:/phpstudy_pro/WWW/agwenbi.vip/iview"; location / { try_files $uri $uri/ @router;...

需要配置下nginx,位置在/conf/vhosts/*.conf,将当前目录下的所有conf都修改一下最好

vue在history的路由模式下,刷新后界面报404

server {
        listen        80;
        server_name  agwenbi.vip;
        root   "C:/phpstudy_pro/WWW/agwenbi.vip/iview";
        location / {
            try_files $uri $uri/ @router;
            index index.html;
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
        location @router {
            rewrite ^.*$ /index.html last;
        }
gzip  on;
gzip_disable “MSIE [1-6].(?!.*SV1)”;
gzip_http_version 1.1;
gzip_vary on;
gzip_proxied any;
gzip_min_length 5000;
gzip_buffers 16 8k;
gzip_comp_level 6;
gzip_types text/css text/xml text/plain text/javascript application/javascript application/json application/xml application/rss+xml application/xhtml+xml;
}

 

本文地址:https://blog.csdn.net/Ag_wenbi/article/details/107166890