服务器建站 -- 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>
上一篇:走进MongoShake


下一篇:爬虫(八):分析Ajax请求抓取今日头条街拍美图