How to Repair WordPress 500 Internal Error after installing W3Cache Plugin

Occasionally, after installing a new WordPress plugin you can get a 500 internal server error.  This problem is compounded by being unable to access any page on the site.  This includes both the front facing pages as well as the back-end administration section used to install and uninstall plugins.

I recently had this issue after installing W3 Cache plugin.  I did a quick google search and came across a lot forums asking for help on this exact issue.  It took a lot of shifting through different forums to determine that it was not going to be as simple as just deleting the specific plugin folder.  Turned out the repair was almost that easy.

If the repair does not work I have also provided uninstall instructions for W3 Cache – Jump to Uninstall Instructions

Repair

Steps to attempt to repair the W3 Cache plugin causing a 500 internal server error

  1. ftp into the WordPress installation and download the .htaccess file found the in the root of the installation directory.
  2. Open file in your preferred text editor.
  3. Find  in the code a misplaced comment starting with # BEGIN W3TC Browser Cache
  4. Move this line to its own line. (The Apache server sees # as a comment but must be at the beginning of a line).
  5. Save and upload your newly modified .htaccess file.

Using the above example the code would this look like this:

RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
 RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]
 RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
 RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
 RewriteRule . index.php [L]
 # BEGIN W3TC Browser Cache
 <IfModule mod_deflate.c>
 <IfModule mod_headers.c>
 Header append Vary User-Agent env=!dont-vary
 </IfModule>
 AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
 <IfModule mod_mime.c>
 # DEFLATE by extension
 AddOutputFilter DEFLATE js css htm html xml
 </IfModule>
 </IfModule>
 # END W3TC Browser Cache

Uninstall

Steps to completely uninstall the W3 Cache plugin from WordPress

  1. ftp into the WordPress installation and navigate to <Installed Directory>/wp-content/plugins and delete the plugin.
  2. Delete this file as well /wp-content/advanced-cache.php 
  3. Download the .htaccess file and open in your favorite text editor.
  4. Delete everything highlighted starting with # BEGIN W3TC Browser Cache to # END W3TC Browser Cache
  5. Save and upload your newly modified .htaccess file.

Here is the .htaccess file.

RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
 RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]
 RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
 RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
 RewriteRule . index.php [L]# BEGIN W3TC Browser Cache
 <IfModule mod_deflate.c>
  <IfModule mod_headers.c>
  Header append Vary User-Agent env=!dont-vary
  </IfModule>
  AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
  <IfModule mod_mime.c>
  # DEFLATE by extension
  AddOutputFilter DEFLATE js css htm html xml
  </IfModule>
 </IfModule>
 # END W3TC Browser Cache

Leave a Reply