Reputation: 22760
I am working on a website that is not on my own server, I do not have much (any) access to the server settings outside of the website SFTP.
The server previously ran PHP 5.21 and I used
header("X-Powered-By:");
To overwrite and remove the X-Powered-By header. This worked, but I have found that since the server was updated to PHP 5.6 that this no longer works, and the headers produced is:
X-Powered-By:
X-Powered-By: PleskLin
I didn't expect multiple lines of the same header, so I tried adding code to the page
header_remove("X-powered-by");
but the PleskLin
header remains. Obviously the header is being added after PHP is processing the page, so bearing that in mind and it's a server I am really not familiar with.
Also running
header_remove();
Does not remove the X-Powered-By
header but does remove other PHP set headers.
Upvotes: 2
Views: 1797
Reputation: 22760
I have found that setting header_remove
in the PHP and (strangely) also adding an .htaccess
with the following does remove all X-Powered-By
headers:
<IfModule mod_headers.c>
Header unset X-Powered-By
</IfModule>
To explain: Original header given out is :
x-Powered By: Plesklin
If I simply added the .htaccess
removal code, the header became
X-Powered-By: PHP 5.6.1
but then combined with the on-page header_remove('X-Powered-By')
this cleared all values for that particular header.
Upvotes: 3
Reputation: 21531
The only way you can do this is to ask the host to set expose_php to off in the php.ini file for you.
Upvotes: -1