Replace header

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
superdez
Forum Commoner
Posts: 33
Joined: Tue Jul 03, 2007 1:36 pm

Replace header

Post by superdez »

Is there any way to replace the Server header ?

Code: Select all

<?php
header('Server: Red Hat Linux', true,);
?>
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Have you tried it?
superdez
Forum Commoner
Posts: 33
Joined: Tue Jul 03, 2007 1:36 pm

Post by superdez »

Yes, it doesn't replace my default one.

Any ideas ?
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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.
superdez
Forum Commoner
Posts: 33
Joined: Tue Jul 03, 2007 1:36 pm

Post 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 ?
User avatar
stereofrog
Forum Contributor
Posts: 386
Joined: Mon Dec 04, 2006 6:10 am

Post 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
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I doubt very much it will. There's a specific reason why that feature was implemented in mod_security.
Post Reply