Iis 7 URL重写500.52:无法识别的元素';服务器变量';

Iis 7 URL重写500.52:无法识别的元素';服务器变量';,iis-7,reverse-proxy,url-rewrite-module,Iis 7,Reverse Proxy,Url Rewrite Module,我需要只使用web.config实现一个反向代理,但我遇到了500.52错误。正如在线许多地方建议的那样,我添加了serverVariables部分以包含HTTP_ACCEPT_编码变量,但我遇到了一个错误: 配置错误无法识别的元素“serverVariables” 下面是我的web.config <rewrite> <allowedServerVariables> <add name="HTTP_ACCEPT_ENCODING" /&g

我需要只使用web.config实现一个反向代理,但我遇到了500.52错误。正如在线许多地方建议的那样,我添加了serverVariables部分以包含HTTP_ACCEPT_编码变量,但我遇到了一个错误:

配置错误无法识别的元素“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应该是一个可识别的元素。

您需要将服务器变量事先注册到

中。您需要将服务器变量事先注册到

中。我复制了给出的示例,并根据需要更改了部分

<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>

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

<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>