Blog of Attomsoft Inc.
Drupal 500 internal server error caused by .htaccess file
I encountered 500 internal server error when I tried to access a fresh Drupal 6 installation on a shared host.
The first error appeared on the index page immediately after the Drupal installation. I did some search and found that some options of the default .htaccss file may cause this issue, here are the cause and solutions:
- If you had enabled the clean url feature on installation, the “RewriteBase” should be checked, make sure the path had been set accordingly.
- If the PHP handler runs as CGI mode, some options in .htaccess file are not allowed, especially the “<IfModule mod_php*.c>” sections, comment them out and try to change the settings just in your php.ini file.
- Make sure “Options” overriding allowed by the host.
That’s the first 500 internal server error solutions I found and the #2 solution worked for me. Try your own way on the error raised.
The second 500 error appeared when I tried to access any of the image files I had uploaded to the sites/default/files/ folder. This is weird and need some tricky ways.
- Enter the sites/default/files folder, you can see the .htaccess there, shocked, right? I was.
- According the Drupal official documents, the file is there for security reasons, and Drupal always tries to create it if it’s not there, AND it will always have the same lines when created automatically.
- The .htaccess file has three lines, looks like this:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks
Some host server may not allow the SetHandler option here, especially on some shared host.
The “+FollowSymLinks” is not allowed on most of CGI mode shared host. - I didn’t try to fix the problem by modify the file, just clear all lines and keep it blank. Maybe not professional, but works.
DO NOT remove the .htaccess file in the sites/default/files folder and try to get the result, it will appear again automatically, that’s by design.
Some possible reasons which could rise the 500 internal server error on Drupal site I’ve found:
- PHP safe_mode is set on;
- Drupal can’t access /tmp folder;
- PHP memory limit is too low or run time limit is too short;
Recommendation: Try to contact with the hosting provider first before you buy their service, find out whether Drupal could run fluently. Choosing a wrong hosting provider is just waste your money.
| Print article | This entry was posted by Sean on March 22, 2010 at 10:14 am, and is filed under Drupal. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 1 year ago
Hi Sean,
Thank you for this solution.
I ran into an issue with the .htaccess file on my Drupal installation as well. I was unable to open any files in “drupal/files” folder… basically, I couldn’t view any images or attachments that I uploaded. I would always get the same “Server Error” message.
I found that the “drupal/files” folder in my installation had an .htaccess file created there. I followed your solution #2, it worked perfectly for me. Just wanted to post this feedback for any other developers/designers who run into the same issue.
Thanks!
about 8 months ago
just wanted to say that this post is a god save! could not find out my problem until reading this. keep posting!!
about 4 months ago
Thanks – its working perfectly but the solution is weird.