Page 1 of 1

Replace header

Posted: Tue Jul 10, 2007 3:23 pm
by superdez
Is there any way to replace the Server header ?

Code: Select all

<?php
header('Server: Red Hat Linux', true,);
?>

Posted: Tue Jul 10, 2007 3:28 pm
by RobertGonzalez
Have you tried it?

Posted: Tue Jul 10, 2007 3:30 pm
by superdez
Yes, it doesn't replace my default one.

Any ideas ?

Posted: Tue Jul 10, 2007 3:34 pm
by Ollie Saunders
It never occurred to me to do that but I just tried it and it didn't work. Your best bet it to use mod_security and read this.
In order for this directive to work you must leave/set ServerTokens to Full.
This is because mod_security writes directly over memory concerned to achieve this and enough memory has to be allocated in the first place.

Posted: Tue Jul 10, 2007 3:44 pm
by superdez
I don't have access to httpd.conf only .htaccess but anyway isn't PHP called after, so it should "override" it ?

I can use php to override an error header (say change 403 to 404), so why can't I override a server header ?

Posted: Tue Jul 10, 2007 4:00 pm
by stereofrog
From my understanding, Server header is issued by Apache *after* php is processed, so no chances.

If your host has mod_headers installed, you can try Headers directive.
http://httpd.apache.org/docs/2.0/mod/mo ... tml#header

Posted: Tue Jul 10, 2007 6:07 pm
by Ollie Saunders
I doubt very much it will. There's a specific reason why that feature was implemented in mod_security.