Forum Moderators: phranque

Message Too Old, No Replies

How can I change the Content-Type of CGI scripts?

         

guarriman

5:29 pm on Nov 12, 2007 (gmt 0)

10+ Year Member



Hi.

Working with Apache 2.0 (on a customer's server and on my own server),
I've got a '500 Internal Server Error' with a CGI application. When
accessing 'http://customer_machine/test.cgi', Firefox tries to
download the error webpage.

But when accessing 'http://my_own_machine/test.cgi', Firefox shows the
HTML error webpage.

Analyzing headers

---------------------------------------
[customer_machine...]
HTTP/1.1 500 Internal Server Error
Content-Type: application/x-cgi
----------------------------------------

--------------------------------------
[my_own_machine...]
HTTP/1.1 500 Internal Server Error
Content-Type: text/html; charset=iso-8859-1
--------------------------------------

How can I change the Content-Type of CGI scripts?

Thank you very much.

Receptional Andy

7:56 pm on Nov 12, 2007 (gmt 0)



For portability, you can set the content type within your script itself (e.g. in perl print "Content-type: text/html\n\n";).

This can also be changed at the server level via config changes (on Apache either via htaccess or httpd.conf).

phranque

11:26 pm on Nov 12, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



For portability, you can set the content type within your script itself (e.g. in perl print "Content-type: text/html\n\n";).

these must be the first characters written by your script to standard output.