官方说明文档:

https://router.vuejs.org/zh/g...

一、 实测 Linux 系统 Apache 配置:

更改站点配置文件即可,我这里在 Directory 标签后面添加了官方给的五行配置


<VirtualHost *:80>
#Created by linvic on 2018-05-24
Serveradmin 674206994@qq.com
ServerName blog.xxx.com
DocumentRoot /home/www/blog <Directory "/home/www/blog">
Options FollowSymLinks
AllowOverride All
#Require all denied
Require all granted
RewriteEngine On RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L] </Directory>
</VirtualHost>

二、 实测 Windows 环境下 IIS 配置

1. IIS安装Url重写功能

https://msdn.microsoft.com/zh...

  1. 到该网站下载安装web平台安装程序
  2. 安装后打开到里面搜索安装URL重写功能

2. web.config

将web.config 文件放置于 npm run build 打包后文件的根目录即可。

ps:此文件会自动给IIS上的URL重写功能进行相关配置

文件内容如下:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="font/x-woff2" />
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".ttf" mimeType="font/x-ttf" />
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="text/json" />
</staticContent>
<rewrite>
<rules>
<rule name="vue" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

vue下history模式刷新后404错误解决的更多相关文章

  1. 解决vue路由history模式刷新后404的问题

    server { listen ;#默认端口是80,如果端口没被占用可以不用修改 server_name localhost; root E:/vue/my_project/dist;#vue项目的打 ...

  2. 新来的前端小姐姐问:Vue路由history模式刷新页面出现404问题

    摘要:vue-router 默认 hash 模式 -- 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载. 本文分享自华为云社区<学习Vue Rou ...

  3. vue路由history模式刷新页面出现404问题

    vue hash模式下,URL中存在'#',用'history'模式就能解决这个问题.但是history模式会出现刷新页面后,页面出现404.解决的办法是用nginx配置一下.在nginx的配置文件中 ...

  4. vue下使用nginx刷新页面404

    nginx 是一个代理的服务器.出现的问题:写好的页面通过nginx作为代理的服务器给别的同事看的时候发现了新写的页面打开就404,并且从其他页面跳转可以看到但是刷新页面就404.解决方法:在文件中的 ...

  5. vue路由history模式刷新404问题解决方案

    更改router 的base // biz是二级目录,路由文件改成 const router = new VueRouter({ mode: 'history', // base: process.e ...

  6. Servlet访问第一次500,刷新后404的解决办法

    第一次运行错误:HTTP Status 500 -  --------------------------------------------type Exception reportmessage  ...

  7. antdpro 打包部署后访问路由刷新后404

    antdpro build 后访问路由刷新后 404? 解决方法有三种: 1. 改用 hashHistory,在 .umirc.js或者是config.js 里配 history: 'hash' 2. ...

  8. Vue项目history模式下微信分享总结

    原文 : http://justyeh.top/post/39/ 2019-07-02 Vue微信分享 每回遇到微信分享都是一个坑,目前的商城项目使用Vue开发,采用history的路由模式,配置微信 ...

  9. 在nginx上部署vue项目(history模式);

    在nginx上部署vue项目(history模式): vue-router 默认是hash模式,使用url的hash来模拟一个完整的url,当url改变的时候,页面不会重新加载.但是如果我们不想has ...

随机推荐

  1. Shell编程—sed进阶

    1多行命令 sed编辑器包含了三个可用来处理多行文本的特殊命令. N:将数据流中的下一行加进来创建一个多行组来处理. D:删除多行组中的一行. P:打印多行组中的一行. 1.1next命令 1. 单行 ...

  2. k8s-1.15.0集群部署+dashboard

    环境:外网环境硬件master-centos7.4  2核4G node1-centos7.4     2核4Gnode2-centos7.4     2核4G软件:三台服务器 :docker-19. ...

  3. composer分析(二)结合PSR-4

    composer分析(二)结合PSR-4 PSR-4提供了一种文件和路径映射关系,非常类似文件系统的组织结构 全限定类名 \<NamespaceName>(\<SubNamespac ...

  4. AndroidStudio与eclipse打包的时候报错。Error:(4) Error: "ssdk_instapager_login_html" is not translated in "en"

    作者:程序员小冰,CSDN博客:http://blog.csdn.net/qq_21376985 QQ986945193 博客园主页:http://www.cnblogs.com/mcxiaobing ...

  5. 跨平台C# UI库

    https://github.com/AvaloniaUI/Avalonia https://www.cnblogs.com/leolion/p/7144896.html https://github ...

  6. Lua C API的正确用法

    http://blog.codingnow.com/2015/05/lua_c_api.html http://blog.csdn.net/oilcode/article/details/510861 ...

  7. Mac OSX上安装Nginx

    1. 通过brew instal nginx安装 ==> Downloading https://homebrew.bintray.com/bottles/nginx-1.10.1.el_cap ...

  8. 关于java的二维码的生成与解析

    本文说的是通过zxing实现二维码的生成与解析,看着很简单,直接上代码 import java.io.File; import java.io.IOException; import java.nio ...

  9. Linux服务器关联Git,通过执行更新脚本实现代码同步

    1.在Linux服务器安装Git yum install git -y   tips: 卸载Git :  yum remove git   2.在Linux生成ssh key   1)创建用户 git ...

  10. 被Spring坑了一把,查看源码终于解决了DataFlow部署K8s应用的问题

    1 前言 欢迎访问南瓜慢说 www.pkslow.com获取更多精彩文章! Docker & Kubernetes相关文章:容器技术 基于各种原因,团队的Kubernetes被加了限制,必须在 ...