【问题标题】:404 File or directory not found with query subpath404 找不到带有查询子路径的文件或目录
【发布时间】:2019-09-16 05:16:51
【问题描述】:

IIS 10 抛出错误

404 File or directory not found

仅当我尝试使用这样的子文件夹路径访问 url 时:

http://myserveraddress.com/object/181

所以它可以在没有子文件夹的情况下工作。子文件夹路径是Angular用来查询rest接口的,所以后面没有物理文件夹路径,只用于schene后面的查询。

这实际上在本地主机上运行但在服务器上运行时有效。

是否可以将 IIS 配置为允许任何 url 路径,即使物理文件夹路径不存在?

【问题讨论】:

    标签: iis


    【解决方案1】:

    这更像是处理程序配置问题,而且如果您的服务器是全新的服务器,您可能还没有安装应该处理您的请求的处理程序,如果我必须接受请求,如果您没有t 配置了所需的其余处理程序,它将转到静态文件处理程序,该处理程序尝试在请求 url 路径中查找文件夹并引发错误,如果您已经运行了设置,请检查那里安装的所有处理程序和先决条件,并且模仿新服务器中的设置

    【讨论】:

      【解决方案2】:

      解决方案是将其添加到 Angular 客户端 web.config 文件中

      <configuration>
        <system.webServer>
          <rewrite>
            <rules>
              <rule name="AngularJS Routes" 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>
      

      更多细节可以在这里找到Get Angular2 routing working on IIS 7.5

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-02-25
        • 1970-01-01
        • 2022-06-13
        • 2014-07-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-18
        相关资源
        最近更新 更多