【问题标题】:"The connection was reset" error caused by specific .htaccess rule由特定 .htaccess 规则引起的“连接已重置”错误
【发布时间】:2018-09-13 15:22:54
【问题描述】:

我最近将本地开发环境升级到 Apache 2.4.33 和 PHP 7.1.7

使用以前版本的 Apache 和 PHP 没有这样的问题。

我有一个 css 文件,它直接从浏览器 /css/styles.min.css 调用它工作正常,直到我更新文件内容并保存它,但现在在 Firefox 和 Chrome 中我得到相当于“连接已重置”的错误.

文件权限和所有权都很好。没有问题。

我可以暂时修复它。我已将其缩小到 .htaccess 文件中的一行

RewriteRule (.*)\.1[0-9]+\.(jpg|jpeg|gif|css|js) $1.$2

该行正在使用,但与看到错误的文件不匹配。注释掉该行可以解决 Firefox 和 Chrome 中的问题。

某处必须有一个错误日志可以提出解决方案,但我在 error_log 或 access_log 中找不到它

真的很奇怪。希望有人可以提出一些我可以尝试的建议?

更新

如果我只在 .htaccess 文件中保留最少的内容,问题就不再发生,即使该行处于活动状态。

【问题讨论】:

    标签: apache .htaccess localhost


    【解决方案1】:

    看起来与mod_deflate相关

    我不知道为什么删除 .htaccess 文件的单行会暂时解决问题,但下面的更新解决了 css 文件的这个问题以及 php 解析的另一个 url 的另一个问题,它给出了相同的错误。所以我现在可以将 .htaccess 重定向恢复到以前的状态。

    我换了:

    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/javascript application/x-javascript application/javascript text/x-component
    AddOutputFilterByType DEFLATE text/richtext text/plain
    AddOutputFilterByType DEFLATE image/svg+xml text/xsd text/xsl text/xml image/x-icon
    AddOutputFilterByType DEFLATE application/json
    </IfModule>
    

    在没有模块的情况下更新版本,apache >= 2.4 或

    <IfModule mod_deflate.c>
    
      # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
      <IfModule mod_setenvif.c>
        <IfModule mod_headers.c>
          SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
          RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
        </IfModule>
      </IfModule>
    
      # HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
      <IfModule filter_module.c>
          <IfModule version.c>
              <IfVersion >= 2.4>
                  FilterDeclare  COMPRESS
                  FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} =~ m#^text/(html|css|plain|xml|x-component)#i"
                  FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} =~ m#^application/(javascript|json|xml|xhtml+xml|rss+xml|atom+xml|vnd.ms-fontobject|x-font-ttf)#i"
                  FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} =~ m#^image/(svg+xml|x-icon)#i"
                  FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'font/opentype'"
                  FilterChain    COMPRESS
                  FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
              </IfVersion>
              <IfVersion < 2.4>
                  FilterDeclare COMPRESS
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
                  FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
                  FilterChain COMPRESS
                  FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
              </IfVersion>
          </IfModule>
          <IfModule !version.c>
              FilterDeclare COMPRESS
              FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
              FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
              FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
              FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
              FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
              FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
              FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
              FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
              FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
              FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
              FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
              FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
              FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
              FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon
              FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
              FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
              FilterChain COMPRESS
              FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
          </IfModule>
      </IfModule>
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 2016-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多