Qianshi's Blog
77 字
1 分钟
VueRouter history mode iis config
2021-07-25
  1. 安装插件:https://www.iis.net/downloads/microsoft/url-rewrite

  2. 配置web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".woff" mimeType="font/x-font-woff" />
        </staticContent>
	      <rewrite>
            <rules>
              <rule name="API Rule" stopProcessing="true">
                <match url="^(api|account|manage)(.*)$" />
                <action type="None" />
              </rule>
              <rule name="Angular Rule" 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.config.js 中 publicPath 修改为 './'**
VueRouter history mode iis config
https://kuriyama.top/posts/vue/vue-router-history-mode-iis-config/
作者
Qian Shi
发布于
2021-07-25
许可协议
CC BY-NC-SA 4.0