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
使用界面配置
- 选择网站,选择 URL重写
- 在URL重写界面,点击右上角 添加规则选择空白规则选名称随便写,填写要匹配的URL模式,正则表达式如果要匹配所有连接,模式设置为:.* 即可,这里我需要匹配subapp/test**/这里重载为目录下的index.html,模式设置为:^subapp/.*设置条件,添加条件,选择不是文件操作,设置重写URL为index.html点击右上角应用即可
如果有多个规则,可以调整规则顺序,来实现匹配
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
post YES开发框架