Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Content-Type header in apache

How to remove header content-type in apache ?

The following code does not work

header_remove('content-type');

like image 403
Mostafa Hosseini Avatar asked Aug 20 '13 04:08

Mostafa Hosseini


3 Answers

Try

<?php
header('Content-Type:');

This completely removed the Content-Type header from the response. Like you, using header_remove() didn't do a thing and Hereblur's answer left me with Content-Type: none in the response.

like image 146
9 revs Avatar answered Oct 18 '22 17:10

9 revs


It depends on what php.ini directives you have, and what PHP you use (CLI, CGI, ...).

This answer is based on PHP 5.4, running in CGI.

Note in php.ini:

default_mimetype = text/html

That's the default value, that PHP sends as:

Content-Type: text/html

If you want to get rid of it, you have to remove the default value by creating the header again, then you can remove the header:

<?php
header('Content-Type: text/html');
header_remove('Content-Type');
like image 5
Yvan Avatar answered Oct 18 '22 18:10

Yvan


Try this.

header("content-type: none");

I don't know why, but it's worked for me.

I cannot find any reference mentioned about this. but it's simply removed the content-type from header for me. It' may be apache's bug or PHP's bug. So try it and use it with careful.

like image 2
Hereblur Avatar answered Oct 18 '22 19:10

Hereblur