Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:config:understanding_500 [2018/06/07 19:15]
Jackson Zhang [Permission or Ownership Changes]
litespeed_wiki:config:understanding_500 [2018/07/18 15:23]
Lisa Clarke [Example 1]
Line 35: Line 35:
 ===== Faulty .htaccess ===== ===== Faulty .htaccess =====
 There is a huge range of things ''​.htaccess''​ can do and it isn't difficult to use, however, if you do not enter the syntax correctly it can result in a Server 500 Error. ​ There is a huge range of things ''​.htaccess''​ can do and it isn't difficult to use, however, if you do not enter the syntax correctly it can result in a Server 500 Error. ​
 +
 +==== Example 1 ====
 For example, ​ For example, ​
   RewriteRule ^(.*) http://​www.example.com/​$1 [P]   RewriteRule ^(.*) http://​www.example.com/​$1 [P]
 Will cause a 500 error. But change it to Will cause a 500 error. But change it to
   RewriteRule (.*) http://​www.example.com/​$1 [R=301,L]   RewriteRule (.*) http://​www.example.com/​$1 [R=301,L]
-And that will fix the issue.+and that will fix the issue. 
 + 
 +==== Example 2 ==== 
 +<​Directory>​...</​Directory >​ can not be used in .htacess and it will cause 500 error for Apache, While LSWS will ignore the unsupported directive instead of giving 500 error. 
 + 
 +For example, the following should not be used in .htaccess. 
 +  <​Directory /​home/​user1/​public_html/​wp-admin/>​ 
 +    Deny from all 
 +  </​Directory>​ 
 + 
 +instead, you can create .htaccess under /wp-admin/ and place diretive there. 
 +  Deny from all
  
 To confirm whether a misconfiguration in ''​.htaccess''​ is the cause of the 500 Internal Server error, either remove or rename the .htaccess file temporarily and then try to reload the page. To confirm whether a misconfiguration in ''​.htaccess''​ is the cause of the 500 Internal Server error, either remove or rename the .htaccess file temporarily and then try to reload the page.
  
 +===== Different level of Rewrite rules misplaced to the wrong level =====
 +
 +Per virtual host rewrite rules (rewrite rules in Apache virtual host configuration) and per directory rewrite rules (rewrite rules in .htaccess) are different. ​ When placing the same rules to the wrong place, it may cause 500 error.
 +
 +For example, the following works in .htaccess: ​
 +
 +  RewriteEngine On
 +  RewriteCond %{REQUEST_FILENAME} !-f
 +  RewriteRule . /index.php [L]
 +  ​
 +Putting the same thing in Apache VirtualHost config doesn’t work at all:
 +
 +  <​VirtualHost *:80>
 +    ServerName example.com
 +    DocumentRoot /​var/​www/​example/​
 +    <​Directory /​var/​www/​example/>​
 +        Allow From All
 +    </​Directory>​
 +    RewriteEngine On
 +    RewriteCond %{REQUEST_FILENAME} !-f
 +    RewriteRule . /index.php [L]
 +  </​VirtualHost>​
 +
 +Apache doesn’t tell you why it doesn’t work. It just doesn’t work. You most likely will get an Error 500 status with a message in the logs that looks like this:
 +
 +Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.
 =====  Improperly Configured php.ini ===== =====  Improperly Configured php.ini =====
 An improperly configured ''​php.ini''​ may lead to 500 error. ​ An improperly configured ''​php.ini''​ may lead to 500 error. ​
Line 142: Line 181:
 ===== Hacked Site ===== ===== Hacked Site =====
 If your site is being hacked, it may trigger a 500 error. If your site is being hacked, it may trigger a 500 error.
 +
 +===== Perl script missing "​Content-Type"​ header may return 500 =====
 +
 +Run a simple "Hello World" perl script at http://​exmaple.com/​cgi-bin/​test.pl but it return 500 error.
 +
 +vi test.pl
 +<​code>​
 +  #​!/​usr/​bin/​perl
 +  print "​Hello,​ World!\n";​
 +</​code>​
 +
 +A Perl CGI script must output the header, HTML code and also must begin with a special first line. In this case, header "​Content-type"​ is missing and it is not a CGI script. Please also be aware that there is a blank line after **print "​Content-Type:​ text/​html\n\n";​**.
 +
 +the right script should be:
 +<​code>​
 +<​code>​
 +  #​!/​usr/​bin/​perl
 +  ​
 +  print "​Content-Type:​ text/​html\n\n";​
 +  ​
 +  print "​Hello,​ World!\n";​
 +</​code>​
 +You can check the example [[https://​users.cs.cf.ac.uk/​Dave.Marshall/​PERL/​node196.html|here]].
  • Admin
  • Last modified: 2019/12/10 19:33
  • by Lisa Clarke