其他分享
首页 > 其他分享> > 服务器建站 -- vue部署在服务器apache2上发生页面跳转404问题

服务器建站 -- vue部署在服务器apache2上发生页面跳转404问题

作者:互联网

问题描述

在本地用vue搭建前端测试正常,将dist文件夹抛到服务器端,访问出现跳转页面显示404报错的异常

问题解决

详见Error 404 on reload or direct URL with Vue and Apache
That is due to the history push mode on your vue router. https://router.vuejs.org/guide/essentials/history-mode.html

If your Apache version is above 2.2, you can use Fallback ressource instead of mod_rewrite in your apache config. It works for me.

In /etc/apache2/apache2.conf

<VirtualHost *:80>
    ServerName YourServerName(like yourwebsite.com)
    DocumentRoot /var/www/yourAppLocation/dist
    <Directory "/var/www/yourAppLocation/dist">
        FallbackResource /index.html
    </Directory>
</VirtualHost>

标签:vue,dist,apache2,404,跳转,服务器,your
来源: https://www.cnblogs.com/CpyKing/p/15857654.html