简体   繁体   English

URL重写出站规则IIS7

[英]URL Rewrite Outbound Rules IIS7

Experimenting with URL rewrites using this module, however I'm getting the following error when attempting to hit the URL. 尝试使用此模块重写URL,但是在尝试访问URL时出现以下错误。 Looked online for answers, but not sure what the best way to get around this is.... any ideas?? 在网上寻找答案,但不知道解决这个问题的最佳方法是....任何想法?

HTTP Error 500.52 - URL Rewrite Module Error. HTTP错误500.52 - URL重写模块错误。 Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded ("gzip").** 当HTTP响应的内容被编码时,不能应用出站重写规则(“gzip”)。**

IIS received the request; IIS收到了请求; however, an internal error occurred during the processing of the request. 但是,在处理请求期间发生了内部错误。 The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred. 此错误的根本原因取决于哪个模块处理请求以及发生此错误时工作进程中发生的情况。

IIS was not able to access the web.config file for the Web site or application. IIS无法访问网站或应用程序的web.config文件。 This can occur if the NTFS permissions are set incorrectly. 如果NTFS权限设置不正确,则会发生这种情况。

IIS was not able to process configuration for the Web site or application. IIS无法处理网站或应用程序的配置。

The authenticated user does not have permission to use this DLL. 经过身份验证的用户无权使用此DLL。

The request is mapped to a managed handler but the .NET Extensibility Feature is not installed. 请求将映射到托管处理程序,但未安装.NET可扩展性功能。

I've tried the comments by aracntido, but it doesn't seem to work in IIS7. 我尝试了aracntido的评论,但它似乎在IIS7中不起作用。 It works fine on servers with IIS7.5, so I'm not sure whether there is a work around. 它在IIS7.5的服务器上工作正常,所以我不确定是否有解决方法。

The fix is to use this in the web.config: 修复是在web.config中使用它:

<system.webServer>
  <urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" />
</system.webServer>

This is by design, it means that the HTML was already zipped when it became available for the URL Rewrite module, so it couldn't rewrite it because it would have to unzip it first, rewrite it and then zip it again and that is too much processor power. 这是设计的,这意味着当HTML可用于URL Rewrite模块时,HTML已被压缩,因此它无法重写它,因为它必须首先解压缩它,重写它然后再次压缩它,这也是处理器能力强大。 If it is dynamic content, try to rewrite it before compress it. 如果是动态内容,请在压缩之前尝试重写它。

Move Dynamic Compression module after URL Rewrite module in "Modules" at server level (InetMgr). 在服务器级别(InetMgr)的“模块”中的URL重写模块之后移动动态压缩模块。 Disable "log rewritten URL" for the rule (default), otherwise the module will try to be the last one in the pipeline. 禁用规则的“日志重写URL”(默认),否则模块将尝试成为管道中的最后一个。

Static compression is not compatible with outbound rewriting. 静态压缩与出站重写不兼容。

Although disabling static and dynamic compression works nicely this method are not working with *.axd files. 虽然禁用静态和动态压缩很有效,但此方法不适用于*.axd文件。 This files are client side resources, like js, Ajax and so on. 这些文件是客户端资源,如js,Ajax等。 Read more on axd files HERE . 这里阅读更多关于axd文件的信息。

Because this files are compressed automatically. 因为这些文件是自动压缩的。 Read HERE more about why! 这里阅读更多关于为什么!

So easier way to make them work is sending request with setting Accept-Encoding header to empty! 让它们工作的更简单方法是发送请求,将Accept-Encoding标头设置为空! This is possible in two ways: 这可以通过两种方式实现:

  1. [BAD] changing your firefox setting HOW? [坏]改变你的firefox设置怎么样?
  2. [NICE] setting an inbound rule to clear Accept-Encoding in header! [NICE]设置入站规则以清除标头中的Accept-Encoding HOW? 怎么样?

Switching off static compression (unnecessary for my situation) in IIS 7.0 fixed a similar problem where URLs would load but a page refresh would produce a basic error 500. 在IIS 7.0中关闭静态压缩(对我的情况不必要)修复了一个类似的问题,其中URL将加载,但页面刷新将产生基本错误500。

I added index.html to the URL and this refined the error to 'HTTP Error 500.52 - URL Rewrite Module Error. 我将index.html添加到URL,并将错误细化为'HTTP错误500.52 - URL重写模块错误。 Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded ("gzip")' error. 当HTTP响应的内容被编码(“gzip”)'错误时,不能应用出站重写规则。

Thanks to aracntido for pointing this out, you helped me nail the problem. 感谢aracntido指出这一点,你帮我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM