Fehler 500 (Internal Server Error) beheben
Inhalt
Wenn wir eine Sache hassten, dann wäre das, wenn du WP Rocket installierst und anschließend mit einer kryptischen Fehlermeldung wie “500 Internal Server Error” konfrontiert wärst, wo eigentlich deine Website in Glanz und Gloria erscheinen sollte.
Wir hassen es, wenn das passiert, aber unter bestimmten Bedingungen, auf die wir keinen Einfluss haben, passiert es leider manchmal trotzdem. Hier kommt eine Anleitung zur Fehlerbehebung.
Fehler finden
.htaccess sichern und entfernen
Zuallererst verbinde dich bitte mittels FTP mit deinem Server oder Webspace und finde die Datei .htaccess für deine Website. Du findest sie normalerweise im Verzeichnis deiner WordPress-Installation, in selteneren Fällen auch eine Verzeichnisebene höher. Kreiere ein Backup dieser Datei (z.B. unter dem Namen htaccess.bak duplizieren), dann benenne sie um, oder lösche die ganz.
Wenn deine Website jetzt wieder online ist, weisst du, dass der Fehler mit der .htaccess-Datei zusammen hängt. Stelle die originale Datei nun wieder her. Zwar kommt dann auch der Fehler 500 zurück, aber den beheben wir jetzt.
Zielgerichtete Lösung mittels MU Plugin
WP Rocket nutzt 7 PHP-Filter, um 7 Regelblöcke zu deiner .htaccess hinzuzufügen (siehe: Referenz am Ende dieses Artikels).
Damit du den Block identifizieren kannst, der den Fehler 500 verursacht, kreiere ein eigenes MU-Plugin wie folgt:
Hinweis: Lies dazu bitte auch die allgemeinen Informationen in diesem Artikel.
- 1
-
Lege einen neuen Ordner
mu-plugins innerhalb von
wp-content an.
Falls der Ordner mu-plugins dort schon existiert, verwende den existierenden. - 2
-
Lege eine neue Datei an und speichere die folgenden Code-Zeilen darin. Nutze dafĂĽr einen Code- oder Texteditor:
<?php defined( 'ABSPATH' ) or die( 'Cheatin’ uh?' ); /** * Plugin Name: WP Rocket | Fix Error 500 * Description: Prevents the dreaded error 500 from appearing. * Author: WP Rocket Support Team * Author URI: http://wp-rocket.me/ * License: GNU General Public License v3 or later * License URI: http://www.gnu.org/licenses/gpl-3.0.html */ // Each of these lines removes 1 block of WP Rocket rules from .htaccess. add_filter('rocket_htaccess_charset', '__return_false'); add_filter('rocket_htaccess_etag', '__return_false'); add_filter('rocket_htaccess_web_fonts_access', '__return_false'); add_filter('rocket_htaccess_files_match', '__return_false'); add_filter('rocket_htaccess_mod_expires', '__return_false'); add_filter('rocket_htaccess_mod_deflate', '__return_false'); add_filter('rocket_htaccess_mod_rewrite', '__return_false');
- 3
-
Speichere die Datei unter einem beliebigen Namen, aber nutze ausschlieĂźlich lateinische Kleinbuchstaben, Ziffern, oder Bindestriche im Dateinamen. Zum Beispiel:
wp-rocket-fix-500.php - 4
- Lade die Datei in den Ordner mu-plugins aus Schritt 1 hoch.
- 5
- Zuletzt deaktiviere und re-aktiviere WP Rocket einmal.
Sobald du das MU-Plugin hochgeladen und deine Seite im Browser aktualisiert hast, sollte der Fehler 500 verschwunden sein; allerdings hast du jetzt alle Regelblöcke von WP Rocket aus deiner .htaccess entfernt.
Du solltest jedoch nur die Blöcke entfernen, die notwendig sind, damit der Fehler behoben wird.
Das geht so:
- 1
-
Entferne die Zeilen, die mit
add_filter()
beginnen, eine nach der anderen aus dem Plugin. - 2
- Jedes Mal, wenn du eine Zeile entfernt hast, speichere die Plugin-Datei, de-aktiviere und re-aktiviere WP Rocket, und prĂĽfe deine Website.
- 3
- Wenn der Fehler 500 wiederkehrt, weisst du: die Zeile, die du zuletzt entfernt hast, ist die, die den Fehler beheben kann.
- 4
-
FĂĽge diese Zeile wieder hinzu und entferne alle anderen, die mit
add_filter
beginnen.
VoilĂ , du hast den Fehler 500 dauerhaft behoben!
Hinweis: Als alternative Methode zur Fehlersuche kannst du auch deine .htaccess öffnen und jeden Regelblock einzeln entfernen, bis der Fehler 500 verschwindet. Auf diese Weise bekommst du genauso gut heraus, welcher Block den Fehler verursacht, musst allerdings immer noch das MU-Plugin kreieren, um die Lösung dauerhaft zu implementieren.
Hier gibt es ein Video zu dieser alternativen Herangehensweise.
Server-Konfiguration
Falls die bisher beschriebenen Schritte nicht zu einer Lösung führen, solltest du deine Server-Konfiguration überprüfen. Der sinnvollste Weg besteht sicher darin, den Support deines Webhostings zu kontaktieren (besonders, wenn du selbst in Server-Administration nicht wirklich versiert bist).
đź› Die folgenden Hinweise haben einigen unserer Kundinnen und Kunden in der Vergangenheit geholfen:
- cPanel: Stelle sicher, dass Kompression deaktiviert ist.
- Plesk: Die empfohlene Sicherheitseinstellung fĂĽr /wp-content kann einen Error 500 verursachen; deaktiviere diese Option und prĂĽfe, ob das den Fehler behebt.
Referenz: .htaccess-Regeln von WP Rocket
Charset
rocket_htaccess_charset();
# Use UTF-8 encoding for anything served text/plain or text/html AddDefaultCharset UTF-8 # Force UTF-8 for a number of file formats <IfModule mod_mime.c> AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml </IfModule>
ETag
rocket_htaccess_etag();
# FileETag None is not enough for every server. <IfModule mod_headers.c> Header unset ETag </IfModule> # Since we're sending far-future expires, we don’t need ETags for static content. # developer.yahoo.com/performance/rules.html#etags FileETag None
WebFonts
rocket_htaccess_web_fonts_access();
# Send CORS headers if browsers request them; enabled by default for images. <IfModule mod_setenvif.c> <IfModule mod_headers.c> # mod_headers, y u no match by Content-Type?! <FilesMatch "\.(cur|gif|png|jpe?g|svgz?|ico|webp)$"> SetEnvIf Origin ":" IS_CORS Header set Access-Control-Allow-Origin "*" env=IS_CORS </FilesMatch> </IfModule> </IfModule> # Allow access to web fonts from all domains. <FilesMatch "\.(eot|otf|tt[cf]|woff2?)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch>
FilesMatch
rocket_htaccess_files_match();
<IfModule mod_alias.c> <FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$"> <IfModule mod_headers.c> Header set X-Powered-By "WP Rocket/2.6.8" Header unset Pragma Header append Cache-Control "public" Header unset Last-Modified </IfModule> </FilesMatch> <FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$"> <IfModule mod_headers.c> Header unset Pragma Header append Cache-Control "public" </IfModule> </FilesMatch> </IfModule>
ModExpires
rocket_htaccess_mod_expires();
# Expires headers (for better cache control) <IfModule mod_expires.c> ExpiresActive on # Perhaps better to whitelist expires rules? Perhaps. ExpiresDefault "access plus 1 month" # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5) ExpiresByType text/cache-manifest "access plus 0 seconds" # Your document html ExpiresByType text/html "access plus 0 seconds" # Data ExpiresByType text/xml "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType application/json "access plus 0 seconds" # Feed ExpiresByType application/rss+xml "access plus 1 hour" ExpiresByType application/atom+xml "access plus 1 hour" # Favicon (cannot be renamed) ExpiresByType image/x-icon "access plus 1 week" # Media: images, video, audio ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType video/ogg "access plus 1 month" ExpiresByType audio/ogg "access plus 1 month" ExpiresByType video/mp4 "access plus 1 month" ExpiresByType video/webm "access plus 1 month" # HTC files (css3pie) ExpiresByType text/x-component "access plus 1 month" # Webfonts ExpiresByType application/x-font-ttf "access plus 1 month" ExpiresByType font/opentype "access plus 1 month" ExpiresByType application/x-font-woff "access plus 1 month" ExpiresByType application/x-font-woff2 "access plus 1 month" ExpiresByType image/svg+xml "access plus 1 month" ExpiresByType application/vnd.ms-fontobject "access plus 1 month" # CSS and JavaScript ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" </IfModule>
ModDeflate
rocket_htaccess_mod_deflate();
# Gzip compression <IfModule mod_deflate.c> # Active compression SetOutputFilter DEFLATE # Force deflate for mangled headers <IfModule mod_setenvif.c> <IfModule mod_headers.c> SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding # Don’t compress images and other uncompressible content SetEnvIfNoCase Request_URI \ \.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf|mp?g)$ no-gzip dont-vary </IfModule> </IfModule> # Compress all output labeled with one of the following MIME-types <IfModule mod_filter.c> AddOutputFilterByType DEFLATE application/atom+xml \ application/javascript \ application/json \ application/rss+xml \ application/vnd.ms-fontobject \ application/x-font-ttf \ application/xhtml+xml \ application/xml \ font/opentype \ image/svg+xml \ image/x-icon \ text/css \ text/html \ text/plain \ text/x-component \ text/xml </IfModule> <IfModule mod_headers.c> Header append Vary: Accept-Encoding </IfModule> </IfModule>
ModRewrite
rocket_htaccess_mod_rewrite();
<IfModule mod_mime.c> AddType text/html .html_gzip AddEncoding gzip .html_gzip </IfModule> <IfModule mod_setenvif.c> SetEnvIfNoCase Request_URI \.html_gzip$ no-gzip </IfModule> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} on [OR] RewriteCond %{SERVER_PORT} ^443$ [OR] RewriteCond %{HTTP:X-Forwarded-Proto} https RewriteRule .* - [E=WPR_SSL:-https] RewriteCond %{HTTP:Accept-Encoding} gzip RewriteRule .* - [E=WPR_ENC:_gzip] RewriteCond %{REQUEST_METHOD} GET RewriteCond %{QUERY_STRING} ="" RewriteCond %{HTTP:Cookie} !(wordpress_logged_in_|wp-postpass_|wptouch_switch_toggle|comment_author_|comment_author_email_) [NC] RewriteCond %{REQUEST_URI} !^(/_test/|/wp-json/(.*))$ [NC] RewriteCond %{HTTP_USER_AGENT} !^(facebookexternalhit).* [NC] RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}.html%{ENV:WPR_ENC}" -f RewriteRule .* "/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}.html%{ENV:WPR_ENC}" [L] </IfModule>