【问题标题】:URL Rewrite 500.52: Unrecognized element 'serverVariables'URL 重写 500.52:无法识别的元素“serverVariables”
【发布时间】:2018-06-17 13:07:12
【问题描述】:

我需要仅使用我的 web.config 实现反向代理,但遇到了 500.52 错误的问题。正如网上许多地方所建议的那样,我添加了 serverVariables 部分以包含 HTTP_ACCEPT_ENCODING 变量,但我遇到了一个错误:

配置错误无法识别元素“serverVariables”

下面是我的 web.config。

<rewrite>
      <allowedServerVariables>
        <add name="HTTP_ACCEPT_ENCODING" />
    </allowedServerVariables>
      <outboundRules>
        <rule name="reverseProxy">
          <match pattern="http://linkInCode.com"></match>
          <serverVariables>
            <set name="HTTP_ACCEPT_ENCODING" value="" />
          </serverVariables>
          <action type="Rewrite" value="https://linkIWant.com/script.js"></action>
        </rule>
      </outboundRules>
    </rewrite>

有什么问题? ServerVariables 应该是一个可识别的元素。

【问题讨论】:

    标签: iis-7 reverse-proxy url-rewrite-module


    【解决方案1】:

    使用this blog post,我复制了给出的示例并根据需要更改了部分。

    <rewrite>
        <rules>
            <rule name="Rewrite to article.aspx">
                <match url="^article/([0-9]+)/([_0-9a-z-]+)" />
                <action type="Rewrite" url="https://URLtoHide.com" />
            </rule>
    </rules>
    <outboundRules>
        <rule name="Rewrite to clean URL" preCondition="IsHTML">
            <match filterByTags="A" pattern="http://http://URLtoShow.com" />
            <action type="Rewrite" value="https://URLtoHide.com" />
        </rule>
        <preConditions>
            <preCondition name="IsHTML">
                <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
            </preCondition>
        </preConditions>
    </outboundRules>
    

    【讨论】:

      【解决方案2】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-08-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-22
        • 2018-03-21
        • 2020-01-25
        相关资源
        最近更新 更多