Page 1 of 1

[info] mod_rewrite (pretty urls), fastcgi & 500 errors on 404 requests

Posted: Tue Apr 14, 2009 3:40 pm
by pomfret
Throwing this out there in case someone else is using a similar setup and experiencing issues with 500 errors on 404 requests when using mod_rewrite for pretty URLs and a fastcgi based PHP setup.  Note that this only happens when the requested url bypasses the .htaccess 404 redirect (due to rewrite rules) and CMSms tries to handle the situation.

An indication that you are having a similar problem is this server error_log output:
FastCGI: comm with server "/path/to/php5/bin/php" aborted: error parsing headers: duplicate header 'Status'

If you don't feel lilke probing around core CMSms files, you can avoid this issue altogether by setting up your CMSms rewrite rules to use a page extension that doesn't exist in your old site.  Also, there seems to be hope that this issue is not present in PHP v5.3.

My setup is as follows:

Apache/1.3.41
PHP Version 5.2.6 (CGI/FastCGI )
CMSms 1.5.4

There's two edits needed to avoid to 500 errors, as follows:

lib/content.functions.php - line 673
replace:

Code: Select all

header("Status: 404 Not Found");
with:

Code: Select all

if (php_sapi_name() !== 'cgi-fcgi') {
  header("Status: 404 Not Found");
}
lib/misc.functions.php - line 192
replace:

Code: Select all

header("Status: 404 Not Found");
with:

Code: Select all

if (php_sapi_name() !== 'cgi-fcgi') {
  header("Status: 404 Not Found");
}
There's plenty of debate if this is a fastcgi, php, or coding issue, so I will not take on that discussion.  If you're interested in reading more, Google "FastCGI duplicate header Status" for the debates, issues and/or solutions.

Brian

Re: [info] mod_rewrite (pretty urls), fastcgi & 500 errors on 404 requests

Posted: Wed Apr 15, 2009 5:01 pm
by Pierre M.
Hello Brian,

Thank you for the feedback.
pomfret wrote: There's plenty of debate if this is a fastcgi, php, or coding issue, so I will not take on that discussion.
I'm not a PHP coder and I can't participate either.
If you want to follow the topic with the DevTeam it is better to file a report in the forge (where they track issues).

Have fun with CMSms

Pierre M.

Re: [info] mod_rewrite (pretty urls), fastcgi & 500 errors on 404 requests

Posted: Thu Apr 16, 2009 1:10 pm
by pomfret
Greetings Pierre,

Seeing as this is a very case-specific issue, I decided to just report my findings to the forum with the hopes of helping anyone else that runs into a similar situation.

I rather not bother the devs with something that's not confirmed as a bug (I guess this depends on what position you're looking at the issue from).  Also, I'm not a "programmer" either.  With enough time and documentation, I can usually resolve most of my questions/issues.  That hardly qualifies me as knowing what I'm doing.  :)


Brian

P.S. (I'm having an absolute blast with CMSms!)

Re: [info] mod_rewrite (pretty urls), fastcgi & 500 errors on 404 requests

Posted: Fri Apr 17, 2009 8:33 pm
by JeremyBASS
Question... could this not be test for... there for implemented in the core?

Cheers
jeremyBass