特定.htaccess规则引发"The connection was reset"错误(Apache/PHP升级后)
Hey there, let’s dig into this frustrating issue you’re facing after upgrading to Apache 2.4.33 and PHP 7.1.7. Since you’ve already ruled out file permissions and ownership, let’s walk through some targeted fixes:
Verify Apache’s MIME Type Configuration
Sometimes Apache’s default config shifts after an upgrade, and if CSS files aren’t mapped to the correct MIME type, it can cause transfer issues. Check yourhttpd.confor site-specific.htaccessfile to ensure this line exists:AddType text/css .cssIf it’s missing, add it and restart Apache to test.
Check for Interfering Apache Modules
Newly enabled modules (likemod_securityormod_deflate) might be flagging your minified CSS file as suspicious or causing compression errors:- For
mod_security, try adding an exception for your CSS file in.htaccess:<FilesMatch "styles.min.css"> SecFilterEngine Off SecFilterScanPOST Off </FilesMatch> - For
mod_deflate, double-check that its configuration isn’t corrupting the CSS. Temporarily comment out this line if it exists to test:# AddOutputFilterByType DEFLATE text/css
Restart Apache after making changes to see if the error clears.
- For
Ensure PHP Isn’t Trying to Parse the CSS File
An accidental configuration change might have made Apache hand off CSS files to PHP for parsing, which will definitely cause errors. Look inhttpd.confor.htaccessfor lines like this and remove.cssfrom the list:# Remove .css from this line if present AddHandler application/x-httpd-php .php .php5 .cssInspect the CSS File for Hidden Issues
Even a small change to the file could introduce problems:- Check for a UTF-8 BOM (byte order mark) at the start of the file—some servers choke on this. Use a text editor like VS Code to save the file as "UTF-8 without BOM".
- Ensure there are no invalid characters or syntax errors in the updated CSS. Minified files can sometimes have odd artifacts if the minification tool misbehaved.
Dig Into Apache’s Error Logs
This is the most reliable way to get to the root of the problem. Look for entries related tostyles.min.cssin your Apache error log (usually located at/var/log/apache2/error.logon Linux, orlogs/error.login your Apache installation folder on Windows). The log will likely spell out exactly what’s going wrong—whether it’s a module error, file access issue, or something else.
内容的提问来源于stack exchange,提问作者Harry B

