我需要配置 IIS 服务器和 Vue 2 应用程序的帮助,我刚刚安装了
vue 2 application
,并在 Windows IIS 7 server
上进行了生产构建,并且一切正常,只有一件事不起作用:
当我尝试打开任何带有用 vue-router 编写的链接“example mysite.com/somepage
”的页面时,我看到 404 error
,但是如果我单击菜单链接工作正常,如果您只输入主 url 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="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
如vue-router文档中所述,为了使用历史模式,您需要执行以下操作: