"连接已重置"特定.htaccess规则导致的错误

时间:2018-04-04 06:57:19

标签: apache .htaccess localhost

我最近将本地开发环境升级到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文件中保留最小内容,则问题不再发生,即使该行处于活动状态。

1 个答案:

答案 0 :(得分:0)

看起来像mod_deflate相关

我不知道为什么删除.htaccess文件的单行会暂时解决问题,但下面的更新解决了css文件的这个问题,而另一个问题是由php解析的另一个问题,它给出了同样的错误。所以我现在能够将.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&gt; = 2.4或&lt; 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>