如何在 IIS 服务器上配置 Vue 2 应用程序? [英] How to config Vue 2 application on IIS server?

查看:41
本文介绍了如何在 IIS 服务器上配置 Vue 2 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关配置 IIS 服务器和 Vue 2 应用程序的帮助,我刚刚在 Windows IIS 7 服务器 上安装了带有生产版本的 vue 2 应用程序,并且一切正常,仅一件事不起作用:当我尝试打开任何带有用 vue-router 编写的链接example mysite.com/somepage"的页面时,我看到 404 错误,但是如果我点击菜单链接工作好的,如果您只输入主网址 mysite.com,它将打开,但任何其他路线都不起作用!

I need help with config IIS server and Vue 2 application, I just installed vue 2 application with production build on Windows IIS 7 server, and all work fine, only one thing is not working: When I try to open any page with link "example mysite.com/somepage" which written in vue-router i see 404 error, but if I click on menu link work fine, if you type just main url mysite.com it will open, but any another routes not working!

我想我需要设置我的 httpRedirect 或类似的东西!

I think I need to setting my httpRedirect or something like this!

推荐答案

根据你的信息,我假设你正在使用 history 模式,这是我一直在使用的模式,而你可以参考这里:

From your information I'm assuming you're using the history mode, here's the one I've been using, and you can reference on 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 服务器上配置 Vue 2 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆