IIS URL重定向VUE配置


IIS下,VUE Router Mode设置为history后,刷新出现404,

解决方案:

1. IIS安装URL重定向 urlrewrite2.exe

2. 并在项目根目录配置重定向规则,web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
        </staticContent>
        <rewrite>
      <rules>
        <rule name="Handle History Mode and custom 404/500" stopProcessing="true">
            <match url="^pc\/(.*)" />
            <conditions logicalGrouping="MatchAll">
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
          <action type="Rewrite" url="/pc/" />
        </rule>
        <rule name="mobile" stopProcessing="true">
            <match url="^mobile\/(.*)" />
            <conditions logicalGrouping="MatchAll">
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
          <action type="Rewrite" url="/mobile/" />
        </rule>
      </rules>
    </rewrite>
    </system.webServer>
</configuration>
GarsonZhang www.infnitee.com

 

使用界面配置

  1. 选择网站,选择 URL重写 
  2. 在URL重写界面,点击右上角 添加规则
    选择空白规则
    名称随便写,填写要匹配的URL模式,正则表达式
    如果要匹配所有连接,模式设置为:.* 即可,
    这里我需要匹配subapp/test**/这里重载为目录下的index.html,模式设置为:^subapp/.*
    设置条件,添加条件,选择不是文件
    操作,设置重写URL为index.html
    点击右上角应用即可
     
     

如果有多个规则,可以调整规则顺序,来实现匹配

 
 
 
 

 

 

 

版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
YES开发框架
上一篇:VUE IIS根据访问端自动跳转适合的链接
下一篇:IIS配置允许跨域访问
评论列表

发表评论

评论内容
昵称:
关联文章

IIS URL定向VUE配置
IISURL定向配置
vue vue-clie多环境配置
IIS程序池回收配置
IIS中应用程序池自动停止,启报错
权限配置
业务模块特殊URL配置
IIS配置允许跨域访问
VUE qiankun
vue3+vist 打包空白
获取URL参数的几种方式
路由配置
C#使用默认浏览器打开URL
.NET IIS第一次访问慢,程序池被回收问题,IIS初始化(启用预加载)
新建vue项目出现error Unexpected ‘debugger‘ statement no-debugger
YESWEB 开发框架 路由配置文件 作用原理
微信授权连接URL生成类库
修改CPU型号(启依然有效)
服务器IIS离线安装URLRewrite
IIS初始化(预加载),解决第一次访问慢,程序池被回收问题

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码