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开发框架
上一篇:IIS URL重定向VUE配置
下一篇:IIS配置允许跨域访问
评论列表

发表评论

评论内容
昵称:
关联文章

YES-CMS内容管理系统 售价

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