How can I remove X-Powered-By header in PHP? I am on an Apache Server and I use php 5.21. I can't use the header_remove function in php as it's not supported by 5.21. I used Header unset X-Powered-By, it worked on my local machine, but not on my production server.
If php doesn't support header_remove() for ver < 5.3, is there an alternative?
views:
311answers:
3
+6
A:
I think that is controlled by the expose_php
setting in PHP.ini:
expose_php = off
Decides whether PHP may expose the fact that it is installed on the server (e.g. by adding its signature to the Web server header). It is no security threat in any way, but it makes it possible to determine whether you use PHP on your server or not.
Pekka
2010-04-18 09:51:46
+3
A:
If you cannot disable the expose_php directive to mute PHP’s talkativeness (requires access to the php.ini), you could use Apache’s Header
directive to remove the header field:
Header unset X-Powered-By
Gumbo
2010-04-18 09:51:47
That isn't working on my production server. It's working on my local machine though. Any ideas as to why this is happening?
Castor
2010-04-18 10:08:00
@Castor What server versions are you using locally and on the production machine? Any differences in the PHP setup?
Pekka
2010-04-18 10:11:43
PHP Version on production: PHP/5.2.13PHP Version on local: PHP/5.2.11Apache version on production: Apache/2.2.15 (Unix)Apache version on local: Apache 2.0.63 (using MAMP on Mac)
Castor
2010-04-18 10:26:31
@Castor: Is mod_headers available on both servers? And are you allowed to override *FileInfo* (see http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride)?
Gumbo
2010-04-18 11:08:56
@Gumbo Yes, mod_headers is available on both the servers. And yes, I am allowed to override FileInfo.
Castor
2010-04-18 15:16:21
@Castor: Hm, then I don’t see any reason why this wouldn’t work.
Gumbo
2010-04-18 15:38:16