【问题标题】:IIS Server HTML file fallbackIIS 服务器 HTML 文件回退
【发布时间】:2020-08-03 17:58:49
【问题描述】:

我们有一个存储静态 HTML 文件的文件夹和一个还可以呈现网页的服务器。

我们的愿望是当用户访问像http://example.com/trend/phones/ 这样的页面时,IIS 首先检查 HTML 文件是否存在于 example.com/trend/phones/index.html 中,如果存在则将提供该特定的 HTML 文件。但是,如果它不存在,那么它必须代理到服务器,以避免 403 或 404 消息

到目前为止,这是我的规则,但它返回 500

<rule name=“403And404FallBack">
    <match url="(.*)" /> 
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    </conditions>
    <action type="Rewrite" url="http://localhost:3000/{R:1}" />
</rule>

【问题讨论】:

    标签: iis


    【解决方案1】:

    1.请确保您已为您的文件夹trend/phones/指定了默认文档index.html。

    2.请确保已安装ARR并启用转发代理。

    https://docs.microsoft.com/en-us/iis/extensions/configuring-application-request-routing-arr/creating-a-forward-proxy-using-application-request-routing

    3.请确保可以从您的 IIS 服务器访问 http://localhost:3000

      <rule name="rewrite rule">
                        <match url="(.*)\/$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="http://localhost:3000/{R:1}" />
                    </rule>
    

    【讨论】:

    • ARR 已安装。我会试试你的这个解决方案
    猜你喜欢
    • 1970-01-01
    • 2010-09-08
    • 1970-01-01
    • 1970-01-01
    • 2012-12-10
    • 2020-09-26
    • 2022-07-08
    • 2013-07-15
    • 1970-01-01
    相关资源
    最近更新 更多