Forum Moderators: phranque

Message Too Old, No Replies

Redirecting to a perlscript creates an extra http header

really, really strange problem located in this message!

         

moremoneytome

6:12 am on Apr 22, 2004 (gmt 0)

10+ Year Member




Hi!

When I use the RewriteEngine Like this in a .htaccess file the server sends an extra http header. I don't know why.

RewriteEngine on
RewriteRule ^$ cgi-bin/index.pl

The http header shows last on the page, like this:

HTTP/1.0... [my own header]
<html>
...
</html>
HTTP/1.1... [extra header]

(I'm using CGI.pm to create my own http header)

When accessing the perl script directly the extra header does not appear.

When I change the RewriteRule to redirect to a php-file instead of a perl file - no extra http header is sent.

Don't you think that that's strange?

Do anyone have a clue of what that may be wrong?

jdMorgan

3:19 pm on Apr 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well that is strange. If you don't get an answer here, you might try asking in the PERL forum.

<bump>

Jim

moremoneytome

10:22 am on Apr 28, 2004 (gmt 0)

10+ Year Member



I've got some new info about this issue:

The extra http header is only printed when the rewriterule goes to a nph script (non parsed headers). Like this:


RewriteEngine on
RewriteRule ^$ cgi-bin/nph-index.pl

Howerver, when looking in the docs [httpd.apache.org...] there are several examples using a nph script.

I don't understand why it's not working for me.

This is how my perl script looks like (copy from the Cgi.pm docs)


#!/usr/local/bin/perl
use CGI;
$q = new CGI;
print $q->header(),
$q->start_html(-title=>'Wow!'),
$q->h1('Wow!'),
'Look Ma, no hands!',
$q->end_html();

This is the output with the extra header last (in italic):


Content-Type: text/html; charset=ISO-8859-1
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"><head><title>Wow!</title>
</head><body><h1>Wow!</h1>Look Ma, no hands!</body></html>[i]HTTP/1.1 200 OK
Date: Wed, 28 Apr 2004 10:06:12 GMT
Server: Apache/2.0.46 (Unix) mod_perl/1.99_09 Perl/v5.8.0 mod_ssl/2.0.46 OpenSSL/0.9.6g DAV/2 FrontPage/5.0.2.2634 PHP/4.3.2 mod_gzip/2.0.26.1a
Content-Length: 0
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html[/i]

And, yes, I need it to be a non parsed headers script.

Does anyone have a clue of why the extra header is sent?