You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Sean Conner <se...@conman.org> on 2006/02/15 00:56:13 UTC

[users@httpd] Odd interaction between mod_rewrite and mod_cgi

  About eight months ago I wrote about this problem.  Today I had some spare
time to test it again, this time with Apache 2.0.55 and it *still* persists.

  First, the original email:

>   I have a few CGI scripts, written in C (legacy stuff that I don't wish to
> rewrite if possible) that work fine under Apache 1.3.  When moved to Apache
> 2.0.54 (latest version) they still work, but Apache seems to include
> additional output at the bottom of the page:
> 
> 	HTTP/1.1 200 OK Date: Sat, 09 Jul 2005 07:14:04 GMT Server:
> 	Apache/2.0.54 (Unix) DAV/2 Content-Length: 0 Connection: close
> 	Content-Type: text/plain
> 
>   Now, the setup.  It's a stock install of Apache 2.0.54 from source, using
> the pre-fork MPM with all the modules installed as DSOs.  CGIs with an
> extention of .cgi can be run from anywhere, and there's one virtual host
> defined:
> 
> 	<VirtualHost 66.252.224.11>
> 	  ServerName    work.flummux.org
> 	  ServerAdmin   sean@conman.org
> 	  DocumentRoot  /home/spc/blog/htdocs
> 	  CustomLog     logs/work.flummux.org combined
> 	  <Directory /home/spc/blog/htdocs>
> 	    AllowOverride       All
> 	    Options             All
> 	  </Directory>
> 	</VirtualHost>
> 
>   The scripts (there are two, one's just purely for testing) that are
> non-parsed headers CGIs, and indeed, if you go to them directly:
> 
> 	http://work.flummux.org/nph-raw.cgi/test
> 	http://work.flummux.org/nph-blog.cgi/2005/07/08.1
> 
>   you can see they work fine.  Now, I also have a .htacess file with some
> mod-rewrite rules:
> 
> 	RewriteEngine on
> 	RewriteBase   /
> 
> 	RewriteRule   ^([0-9][0-9])(.*) nph-blog.cgi/$1$2 [L]
> 	RewriteRule   ^(test)(.*)       nph-raw.cgi/$1$2  [L]
> 	RewriteRule   ^(foo)(.*)        nph-raw.cgi?$1$2  [L]
> 
>   Hit the following URLs:
> 
> 	http://work.flummux.org/2005/07/08.1
> 	http://work.flummux.org/test
> 	http://work.flummux.org/foo
> 
>   And you'll see the spurious output at the bottom of the pages (at least in
> Firefox and Lynx---the output appears after the </HTML> tag so some browsers
> may ignore it, but it's there).  I did some searches and could not find any
> bugs close to this behavior in Apache 2.0 (this all works fine under Apache
> 1.3, also the main page at http://work.flummux.org/ is a static page so
> that's why there's no spurious output there).  And nothing appears in the
> error log.
> 
>   Have I actually found a big in Apache 2.0.54?

  Some other notes.  Yes, I've tried

	 RewriteRule   ^([0-9][0-9])(.*) nph-blog.cgi/$1$2 [P,L]

  Doesn't work, since I'm not proxying anything.  I've also tried

	RewriteRule   ^([0-9][0-9])(.*) nph-blog.cgi/$1$2 [T,L]

  And I get the same behavior as above.  I even tried

	 RewriteRule   ^([0-9][0-9])(.*) nph-blog.cgi/$1$2 [PT,L]

  And I *still* get the behavior above, only a bit slower.

Is there anything else I'm missing, or can I finally report this as a bug to
the Apache development team?

  -spc (Or perhaps I should try my luck with 2.2?)


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Odd interaction between mod_rewrite and mod_cgi

Posted by Joshua Slive <jo...@slive.ca>.
On 2/15/06, Sean Conner <se...@conman.org> wrote:
> It was thus said that the Great Joshua Slive once stated:
> >
> > In general, there are not many people insterested in nph scripts
> > anymore, so I'd guess that little testing or debugging is done on
> > them.  They aren't useful for very much.
>
>   Be that as it may, but is there some other way for a CGI script to return
> an HTTP status?  That's primarily why *I* use the "nph-" feature (and no,
> rewriting the script in PHP is not an option).
>

Yes, there is a Status header, as in
Status: 404

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Odd interaction between mod_rewrite and mod_cgi

Posted by Joshua Slive <jo...@slive.ca>.
On 2/14/06, Sean Conner <se...@conman.org> wrote:
>
>   About eight months ago I wrote about this problem.  Today I had some spare
> time to test it again, this time with Apache 2.0.55 and it *still* persists.
>
>   First, the original email:
>
> >   I have a few CGI scripts, written in C (legacy stuff that I don't wish to
> > rewrite if possible) that work fine under Apache 1.3.  When moved to Apache
> > 2.0.54 (latest version) they still work, but Apache seems to include
> > additional output at the bottom of the page:
> >
> >       HTTP/1.1 200 OK Date: Sat, 09 Jul 2005 07:14:04 GMT Server:
> >       Apache/2.0.54 (Unix) DAV/2 Content-Length: 0 Connection: close
> >       Content-Type: text/plain

Sounds like:
http://issues.apache.org/bugzilla/show_bug.cgi?id=22898

In general, there are not many people insterested in nph scripts
anymore, so I'd guess that little testing or debugging is done on
them.  They aren't useful for very much.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org