首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >URL重写500.52:未识别的元素“serverVariables”

URL重写500.52:未识别的元素“serverVariables”
EN

Stack Overflow用户
提问于 2018-01-08 14:21:42
回答 2查看 1.4K关注 0票数 0

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

Config错误未识别的元素“serverVariables”

下面是我的web.config。

代码语言:javascript
运行
复制
<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应该是公认的元素。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-04-25 09:22:15

使用这篇博客文章,我复制了给出的示例,并根据我的需要更改了部分。

代码语言:javascript
运行
复制
<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>

票数 1
EN

Stack Overflow用户

发布于 2018-03-03 01:40:47

您需要先前在<allowedServerVariables>中注册服务器变量,

列表

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48152240

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档