当前位置: 移动技术网 > IT编程>脚本编程>vue.js > vue下history模式刷新后404错误解决方法

vue下history模式刷新后404错误解决方法

2018年09月23日  | 移动技术网IT编程  | 我要评论

源远流长造句,蔷花红莲下载,3警察助英拉出逃

本文介绍了vue下history模式刷新后404错误解决方法,分享给大家,具体如下:

官方说明文档:

一、 实测 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 . / [l] 
    
  </directory>
</virtualhost>

二、 实测 windows 环境下 iis 配置

1. iis安装url重写功能

  • 到该网站下载安装web平台安装程序
  • 安装后打开到里面搜索安装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>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网