White screen with WP Rocket and non-writable .htaccess

We’ve been messing around with the WP Rocket caching plugin lately and managed to stumble upon two weird issues that were seemingly unrelated:

  1. Firstly when enabling WP Rocket with just Apache processing and no nginx, it was seemingly unable to write to the .htaccess file (despite having FastCGI access enabled for PHP and definitely having correct permissions and ownership over the files). WP Rocket would give this error: “If you had writing permissions on .htaccess file, WP Rocket could do this automatically. This is not the case, so here are the rewrite rules you have to put in your .htaccess file for WP Rocket to work correctly. Click on the field and press Ctrl-A to select all.
  2. Secondly when trying to clear the cache or refresh the cache, I would get a white screen of death. When I asked their support about this issue, they indicated that wp_get_referer() didn’t seem to be working on our server. Yet there’s no reason why that should be the case!

Call to get_home_path

Upon further investigation of the first issue (figured I’d tackle ’em one at a time) it appeared that the call to get_home_path() was returning simply root: “/” and not the webroot for the site (weird!) I then went to take a peek at the WordPress function to see what it’s up to and discovered a check for inconsistent siteurl and homepath values that would result in a different output than if those values were identical. I then checked my siteurl and homepath values and found one was configured with the WWW and one without… aha!

Fix: Matching the siteurl and homepath

Upon setting siteurl and homepath to the same value, not only did the first issue of detecting a writable .htaccess file disappear, but so too did the issue of the white screen when clearing the cache.

Here’s hoping this solves the problem for others!

Jordan is a computer, security, and network systems expert and a lover of all things web and tech. Jordan consults with project management for software companies. Jordan is a founder and managing partner at Websavers Inc.