Resolving 400 Bad Request Issue on Minified Files

In this article

Identifying an Error 400

In rare cases, when you activate minification there is an issue where your site layout breaks. If you then click on the link to any minified file in the source code of a page, you see the following error message:

<h1>400 Bad Request</h1><p>Please see</p>

This can happen related to certain server configurations.

If you see this issue, you can fix it by installing a custom MU plugin (for better maintainability), or adding a code snippet to your custom theme’s functions.php file, and then clear the WP Rocket cache.

Fix Error 400 via MU Plugin

Follow the general instructions in this article:
How to Make a Custom (MU) Plugin

Create a folder named mu-plugins in your wp-content folder.
In case a mu-plugins folder already exists, don’t create a new one, just use the existing one.
Using a basic text editor create a new file and put the following code in it:
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
 * Plugin Name: WP Rocket | Fix Error 400
 * Description: Fixes error 400 appearing when minification is enabled.
 * Author:      your name here
 * License:     GNU General Public License v3 or later
 * License URI:
add_filter( 'rocket_override_min_documentRoot', '__return_true' );
Save the file as wp-rocket-fix-error-400.php
Upload this file to the mu-plugins folder created in step 1.
Finally, make sure to deactivate and re-activate WP Rocket.

Fix Error 400 from Your Theme

Place the below snippet in the functions.php of your child theme or custom theme.

add_filter( 'rocket_override_min_documentRoot', '__return_true' );