如何在IIS服务器上配置Vue 2应用程序?
问题描述:
我需要配置IIS服务器和Vue 2应用程序的帮助,我刚刚安装了vue 2 application
,生产版本为Windows IIS 7 server
,并且所有工作都正常,只有一件事不起作用: 当我尝试打开任何带有链接“example mysite.com/somepage
”的页面写在VUE路由器我看404 error
,但如果我点击菜单链接工作正常,如果您只键入主要网址mysite.com它将打开,但任何其他路线不工作!如何在IIS服务器上配置Vue 2应用程序?
我想我需要设置我的httpRedirect或类似的东西!
答
从你的信息我假设你正在使用的history
模式,这是我一直在使用一个,你可以在here参考:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" 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="index.html" />
</rule>
</rules>
</rewrite>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" path="/survey/notfound" responseMode="ExecuteURL" />
<error statusCode="500" path="/survey/error" responseMode="ExecuteURL" />
</httpErrors>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
foo.com/#/example? – sandrooco