Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 03-11-2007, 04:33 PM   #1
Registered: Feb 2007
Distribution: Slackware 12.0
Posts: 58

Rep: Reputation: 15
Content-type header in php missing

I'm trying to use php under Apache 1.3, Slackware 11. Perl/CGI is working fine but when I run a PHP script, I get the 'premature header' error which means neither PHP nor Apache is generating the Content-type header. It works if I put the header line 'Content-type: text/html' right at the top of the PHP script, which is not what I thought I was supposed to do. I've searched php.ini and httpd.conf and Google but I can't find out where the header is supposed to be generated in php.

Where do I configure PHP or Apache to generate the content-type header?
Old 03-14-2007, 12:36 AM   #2
Registered: Mar 2007
Location: Bedford, Texas
Posts: 31

Rep: Reputation: 15
Try adding the following lines above your php entries or creating a header.php file that you include in your code:

<title>Page Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />

<?php (your code goes here) ?>

The entry to call your header.php every time is:

<?php include ("header.php") ?>
Old 03-15-2007, 08:06 AM   #3
Registered: Feb 2007
Distribution: Slackware 12.0
Posts: 58

Original Poster
Rep: Reputation: 15
I found the problem! I had ScriptAlias set for the php directory, which tried to execute the php file. I unset ScriptAlias, and it all works fine.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to forward packets based on HTTP header content? varange Linux - Networking 4 11-24-2006 02:39 PM
php & imap: where's the Content-type of one attachment? eantoranz Programming 1 05-26-2006 10:37 AM
content-length HTTP header MPowers Linux - Software 0 04-07-2006 03:01 PM
use CGI vs. content-type: text/html johnensd Red Hat 0 05-09-2004 11:55 PM
Content-Type: multipart/appledouble - Mail Problem WeNdeL Linux - Software 1 09-02-2003 02:04 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:08 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration