iis-7 - 如何在 IIS 服务器上配置 Vue 2 应用程序?

标签 iis-7 vuejs2 windows-server-2008 vue-router

我需要有关配置 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/

相关文章:

iis-7 - 如何在 IIS 7 中为 SSL 配置站点?

Powershell 为所有应用程序池设置 ManagedPipeline

javascript - 无法在链接内插入 vue-router 标签

vue.js - 如何异步验证 Vuetify 文本字段?

configuration - 面向 Internet 的 Windows Server 2008——它安全吗?

regex - IIS 重写规则以检查查询字符串并在它不存在时添加它

v-html 中的 Vue.js <pre> 标签

asp.net - Windows 2008 Server x64 上的 IIS 7.5 ASP 32 位应用程序池上为 500.0 0x800700c1

windows-server-2008 - NT Eventlog 单个消息大小

IIS URL 重写模块 - 更改查询字符串参数值