How to hide the server version and X-Powered-By header
Turn off version details in your web server settings (for example server_tokens off in Nginx or ServerTokens Prod in Apache) and set expose_php = Off for PHP, then restart the service. Hiding the version is a small step; keeping the software updated is what actually protects you.
Every time a browser asks your site for a page, your server replies with hidden information called headers. Two of them often say too much: Server (for example nginx/1.18.0) and X-Powered-By (for example PHP/7.4.3). Anyone can read them, and they tell the world which software you run and which version.
Visitors never see this on the page. It shows up in security scan reports as "server version disclosure" or "information leak", and it is usually quick to fix.
What the headers look like
| Header | Example | What it reveals |
|---|---|---|
Server | Apache/2.4.41 (Ubuntu) | Web server, exact version, sometimes the operating system |
Server | nginx/1.18.0 | Web server and exact version |
X-Powered-By | PHP/7.4.3 | Programming language and version |
X-Powered-By | ASP.NET | Framework in use |
X-AspNet-Version | 4.0.30319 | .NET version |
Why it matters
Showing a version is not a break-in by itself. The problem is that it makes life easier for the wrong people. Automated bots scan thousands of sites looking for a specific old version with a known flaw. If your server says "PHP/7.4.3", you have just told them whether you are worth attacking.
The real risk is old software. The header only advertises it. So treat hiding the version as tidying up, and updating the software as the actual fix.
It can also affect trust and sales. Customers' IT teams, insurers and compliance checks often run scans, and this finding often appears on reports. It has no direct effect on search rankings.
How to check your site for free
- In your browser, open your site, press F12 (or right click and choose Inspect), go to the Network tab, reload, click the first request and look under Response Headers.
- Or run this in a terminal (Mac, Linux, or Windows, where in PowerShell you type
curl.exeinstead ofcurl), replacing the address with yours:
curl -I https://example.com
- Or paste your address into a free header checker such as securityheaders.com, which lists the response headers it receives.
Look for Server lines that include a number, and for any X-Powered-By or X-AspNet-Version line. Check your homepage and also a page that runs code (a PHP page, for instance), because different layers add different headers.
How to fix it
The idea is the same everywhere: tell each layer of your setup to stop announcing itself, then restart it. Menu names and file locations depend on your host and version, so treat the paths below as typical, not guaranteed.
Nginx. In nginx.conf, inside the http block, add:
server_tokens off;
This removes the version number but the header still says nginx. Fully removing the word needs an extra module, which most sites do not need. If PHP sits behind Nginx and passes X-Powered-By through, add fastcgi_hide_header X-Powered-By; in the PHP location block. Then reload Nginx. Step by step: Nginx guide.
Apache. In httpd.conf or apache2.conf (or a security config file on Debian and Ubuntu), set:
ServerTokens Prod
ServerSignature Off
The header then reads just Apache. To remove X-Powered-By, add Header unset X-Powered-By (this needs mod_headers). Restart Apache afterwards. Step by step: Apache guide.
PHP. Find the right php.ini (running php --ini or looking at a phpinfo() page shows which file is loaded) and set:
expose_php = Off
Restart PHP-FPM or the web server so it takes effect. On shared hosting, your control panel may have a PHP settings page where you can change this.
IIS. Open IIS Manager, choose HTTP Response Headers and remove X-Powered-By. For the Server header on IIS 10 and later, removeServerHeader="true" under requestFiltering in web.config usually works. For ASP.NET, setting enableVersionHeader="false" in httpRuntime removes X-AspNet-Version. Step by step: IIS guide.
Other setups.
- cPanel and Plesk: you normally cannot edit the main server config on shared plans. Look for PHP settings in the panel, or ask your host to apply the changes above.
- WordPress: it is PHP underneath, so fix
expose_phpand the server header as above. A plugin cannot change what the server sends before WordPress loads, though some security plugins can remove headers WordPress itself adds. - Cloudflare: it replaces the
Serverheader with its own name, but your origin server still exposes its details if anyone reaches it directly. Response header rules can removeX-Powered-By, but fixing the origin is better. - Node.js (Express):
app.disable('x-powered-by'), or use the Helmet package.
How to confirm it worked
Run the same curl -I command again, or reload the Network tab. The version numbers and X-Powered-By line should be gone. If nothing changed:
- Check that you restarted or reloaded the right service.
- Clear any caching plugin, server cache or CDN cache.
- Test with a private browser window, since your browser may show an old response.
- Check that you edited the config file that is actually loaded, not a spare copy.
How to stop it coming back
These settings are easy to lose. A server upgrade, a new hosting plan, a migration or a reinstall can bring back the defaults. Write down what you changed and where, and ask your developer or host to keep it when they move or rebuild the site.
Most importantly, keep the software current. A hidden version on an outdated server is still an outdated server. Our week 2 security scan checks for this finding each year as part of the OpenVAS scan, and week 31 covers outdated software. Fixing what the report finds is up to you or your developer, and SiteMonday can quote that work separately.
If you are fixing headers anyway, it is a good time to look at the other security headers too, but do them one at a time and test after each change.
Step by step for your platform
- Server version exposed in headers on Nginx
- Server version exposed in headers on Apache
- Server version exposed in headers on IIS
- Server version exposed in headers on cPanel
- Server version exposed in headers on Cloudflare
- Server version exposed in headers on Plesk
- Server version exposed in headers on WordPress
Questions
Is it enough to hide the server version?
No. It removes a clue, but it does not fix any weakness. Updating your web server, PHP and other software is the real protection.
Can I remove the Server header completely?
Often not without extra modules or a proxy in front. Most sites just remove the version number so it says only `nginx` or `Apache`, which is fine.
Will hiding X-Powered-By break my website?
No. Browsers do not use it, and visitors will notice nothing. Just reload and test your site after you restart the service.
Does this affect my Google rankings?
Not directly. The benefit is security and a cleaner scan report, not search position.
I am on shared hosting and cannot edit server files. What can I do?
Check your control panel for PHP settings, or ask your host to turn off version display. Many hosts will do this quickly on request.
Why does my scan still show the version after I changed it?
Usually a cache, a CDN, or a second server layer is still sending it. Restart the service, clear caches and check headers again on both your homepage and a code-driven page.