Fix Internal Server Error in WordPress

If you see the error message Internal Server Error on your WordPress website, something on the site is probably interfering with how the web server processes requests. This guide explains the most common cause – an incompatible .htaccess file – and how to fix it.

How does the error occur?

A common reason for this error is that the site has been moved from our old platform with Apache 2.2 to the new platform with Apache 2.4. This move is necessary because Apache 2.2 reached End of Life in the summer of 2017.

What causes the error and how do you solve it?

The most common cause is that your .htaccess file contains rules that are incompatible with Apache 2.4. Usually a plugin (add-on) such as All in One WP Security & Firewall or W3 Total Cache has added these rules in order to secure or speed up the site.

The quickest way to solve the problem is to log in via FTP and edit the .htaccess file.

The simplest fix is to remove every line in the file except for the default WordPress block below:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Save and re-upload the file.

Advanced solutions

If you want to keep the other rules in .htaccess and still fix the error, here are some tips for specific plugins.

All in One WP Security & Firewall

The All in One WP Security & Firewall plugin includes a built-in firewall called the 5G and/or 6G Firewall. This adds rules to .htaccess that are not supported by Apache 2.4.

The following block needs to be replaced:

# SetEnvIfNoCase User-Agent ^$ keep_out
SetEnvIfNoCase User-Agent (binlar|casper|cmsworldmap|comodo|diavol|dotbot|feedfinder|flicky|ia_archiver|jakarta|kmccrew|nutch|planetwork|purebot|pycurl|skygrid|sucker|turnit|vikspider|zmeu) keep_out

Require all granted
Require not env keep_out
Order Allow,Deny
Allow from all
Deny from env=keep_out

Replace it with:

# 5G:[USER AGENTS]

SetEnvIfNoCase User-Agent ([a-z0-9]{2000,}) bad_bot
SetEnvIfNoCase User-Agent (archive.org|binlar|casper|checkpriv|choppy|clshttp|cmsworld|diavol|dotbot|extract|feedfinder|flicky|g00g1e|harvest|heritrix|httrack|kmccrew|loader|miner|nikto|nutch|planetwork|postrank|purebot|pycurl|python|seekerspider|siclab|skygrid|sqlmap|sucker|turnit|vikspider|winhttp|xxxyy|youda|zmeu|zune) bad_bot

# Apache < 2.3
Order Allow,Deny
Allow from all
Deny from env=bad_bot

# Apache >= 2.3
Require all Granted
Require not env bad_bot

Save and re-upload the file.

W3 Total Cache

Open your .htaccess file as above and delete every line added by W3 Total Cache. If you can log in to the site again, open the WordPress admin area (wp-admin) and uninstall W3 Total Cache. Reinstall it and re-enable the settings you want. The plugin will then detect your server version and insert the correct rules into .htaccess.

WP Fastest Cache

If the site uses WP Fastest Cache and shows this error, you have probably enabled Gzip. See that guide for the solution.

Was this article helpful?

Related Articles