1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Resolve 500 "Internal Server error" error
This guide concerns you if you encounter a 500 error, which can have various origins generally related to the development of your website on a Web Hosting, especially with the rewrites in your .htaccess files.
Under What Circumstances Do These Errors Occur?
Apache2, in use on our servers, no longer supports certain modules like mod_auth_anon, mod_auth_dbm, mod_authz_dbm, mod_cern_meta, mod_imap, mod_imagemap, mod_mime_magic.
Furthermore, Apache2 is strict with syntax errors, and when it encounters syntax errors in an .htaccess file, it can result in 500 Internal Server Error or unexpected URL rewriting errors.
Examples of Incorrect Syntax in .htaccess and Correction
In this first example, the syntax error is that the rewrite rule does not specify the HTTP redirection response code to return. The correction adds the R=301 directive to specify that the redirection should return a 301 (permanent) status code:
RewriteRule ^articles/([0-9]+)/$ /article.php?id=$1 [L]
Correction:
RewriteRule ^articles/([0-9]+)/$ /article.php?id=$1 [L,R=301]
In this second example, the syntax error is that the Options directive does not properly specify the options to enable or disable. The correction adds the "+" sign to specify that FollowSymLinks should be enabled rather than disabled:
Options -Indexes FollowSymLinks
Correction:
Options -Indexes +FollowSymLinks
How to Resolve These Errors?
- If the first page or another page displays a 500 error, rename the .htaccess file or comment out all lines with # and uncomment line by line until you find the problematic section.
- If the error occurs after making changes to one of your pages, the easiest way is to restore the previous version of the file.