我需要有关配置 IIS 服务器和 Vue 2 应用程序的帮助,我刚刚在 Windows IIS 7 服务器
上安装了带有生产版本的 vue 2 应用程序
,并且一切正常,只是一件事不起作用:
当我尝试打开任何带有用 vue-router 编写的链接“example mysite.com/somepage
”的页面时,我会看到 404 错误
,但是如果我单击菜单链接就可以工作很好,如果您只输入主网址 mysite.com 它将打开,但任何其他路线都不起作用!
我想我需要设置我的 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>
关于iis-7 - 如何在 IIS 服务器上配置 Vue 2 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45778566/