7

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.

Castor
  • 1,843
  • 3
  • 15
  • 13
  • expose\_php is an option that can only be set in the .ini file. For apache `header unset` directive to work mod\_header must be installed and you must have FileInfo override privileges. I don't see any other way to remove that header, good for you if I'm wrong ;-) – VolkerK Apr 18 '10 at 18:57
  • @Castor: Have you tried setting the header with no trailing space? `header("X-Powered-By:");`. I always thought this was how headers were unset in older versions of PHP. You could always just leave it in and change it to something bogus: `header("X-Powered-By: Fairies!");` – Andy E Apr 18 '10 at 19:21
  • 1
    I don't understand why you created a new question for this. Just comment on or edit your previous one: http://stackoverflow.com/questions/2661799/removing-x-powered-by see also this question: http://stackoverflow.com/questions/2318806/hiding-phps-x-powered-by-header – Felix Kling Apr 18 '10 at 20:47
  • The purpose of this question is to find out an alternative to header_remove as mentioned in the subject. – Castor Apr 19 '10 at 03:00
  • Which is the same purpose as your other question. I quote: *If php doesn't support header_remove() for ver < 5.3, is there an alternative?* – Felix Kling Apr 19 '10 at 15:23
  • I really wish there was an alternative to header_remove() in this ticket! – Theodore R. Smith Mar 02 '12 at 22:47

1 Answers1

2

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