vue-admin去除地址栏#

vue-admin 发表时间:2020-03-10 16:54:14 作者:梁子亮 浏览次数:867

修改前端src/router/index.js中,开启model为history方式

const createRouter = () => new Router({
  mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

后端修改nginx配置

vim /usr/local/nginx/conf/vhost/log.conf

添加try_files配置,注意先注释掉“try_files $uri =404;”这句

location ~ [^/]\.php(/|$)
{
        # comment try_files $uri =404; to enable pathinfo
        # try_files $uri =404;
        try_files $uri $uri/ /index.html;
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
        #include pathinfo.conf;
}

关于以上官网建议配置location /,但实测配置location ~ [^/]\.php(/|$)也是可行的

完成保存后重启nginx

service nginx restart


上一篇   svm 回滚旧版本