Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to header_remove

Tags:

php

header

I know that header_remove doesn't work in php versions < 5.3 and I use 5.2.1. I am looking for an alternative to header_remove to remove the X-Powered-By header.

I tried using header("X-Powered-By: "); but it still generates a blank header. I tried using Header unset X-Powered-By in .htaccess, but for some reason it's not working. I am stuck here.

like image 722
Castor Avatar asked Apr 18 '10 18:04

Castor


People also ask

How to clear headers in php?

if you want to remove header information about php version (x-powered-by), you can use: header_remove('x-powered-by');

How to hide header in php?

There is an easy way to hide the PHP version from the HTTP headers. By setting the “expose_php” variable to Off in your php. ini file the PHP version would not longer be added to the HTTP headers.

How can I get header in php?

The get_headers() function in PHP is used to fetch all the headers sent by the server in the response of an HTTP request. Parameters: This function accepts three parameters as mentioned above and described below: $url: It is a mandatory parameter of type string.


1 Answers

AFAIK, there is no replacement for this function, but you can either alter the result to something bogus as described above, or configure php.ini to block this header with the following statement:

expose_php = Off
like image 156
Lourenzo Ferreira Avatar answered Sep 28 '22 02:09

Lourenzo Ferreira