Resolve 500 Internal Server Error

It's possible that WP Rocket causes a 500 error on a site. In this article, you will find which steps to follow in this situation, some additional information, and the available fixes. 


Backup .htaccess

The first thing you have to do is to connect via your FTP client and find the .htaccess file for your site. It usually can be found in the root of your server, or your WordPress install. Create a backup of that file, by copying the existing version and renaming it. 

In the original file, remove all of the WP Rocket rules, leaving only the default WordPress rules.

If your site comes back online, you know the problem is related to the .htaccess file. Now put the original file back—the issue will be back, but we are now going to fix it.

Fine tune via helper plugin

WP Rocket uses 7 PHP filters to add 7 blocks of rules to your .htaccess file (see reference at the end of this article).

In order to be able to debug those blocks one by one, install this little helper plugin:

📥  Download (.zip):  WP Rocket | Remove All .htaccess Rules
Developers: you can find the code for this plugin on GitHub.

When you have activated the plugin and reloaded your page in the browser, the error 500 should be gone, but now you have removed all the rule blocks of WP Rocket from your .htaccess file.

However, you should remove only those blocks necessary for the error to stay away.
So let’s do this:

Remove the add_filter() lines from the plugin, one by one.
After each removal, save the file, de-activate and re-activate the helper plugin, and check your site.
When the Error 500 comes back, you know the line you just removed was the one making the error stay away.
Re-add that lastly removed line and remove all other lines beginning with add_filter.

Voilà, that error 500 should be fixed now!

Note: An alternate method of debugging would be to open your .htaccess file and remove each block of rules one by one until the error goes away. That way you would also know which block causes the problem, but you would still have to the helper plugin in order to permanently solve the issue.

Reference: .htaccess rules added by WP Rocket

You can find all the .htaccess rules added by WP Rocket in this article:

WP Rocket rules in the .htaccess file

Each module can be removed with a filter, as follows:

  • Charset - add_filter( 'rocket_htaccess_charset', '__return_false' );
  • ETag - add_filter( 'rocket_htaccess_etag', '__return_false' );
  • WebFonts - add_filter( 'rocket_htaccess_web_fonts_access', '__return_false' );
  • FilesMatch - add_filter( 'rocket_htaccess_files_match', '__return_false' );
  • ModExpires - add_filter( 'rocket_htaccess_mod_expires', '__return_false' );
  • ModDeflate - add_filter( 'rocket_htaccess_mod_deflate', '__return_false' );
  • ModRewrite - add_filter( 'rocket_htaccess_mod_rewrite', '__return_false' );

An action to regenerate the .htaccess file needs to be done after implementing the above as well in order for the changes to take effect.

Increasing memory limit

If you are experiencing 500 Error and removing htaccess rules doesn't help, you should try to Increase memory limit of your server.

"Options not allowed here" error

If you are getting an  Options not allowed here error when WP Rocket is enabled, it can happen if the server disallows options overriding for any reason. We need to override some directives using htaccess rules. Please check the following doc: Apache Directives.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.