How to Disable Server Tokens in WordPress for Better Security

Did you know that WordPress gives away little hints about your server? These hints are called server tokens. They might seem harmless, but they can help hackers figure out how to attack your site. Disabling server tokens is a simple way to improve your website security.

What Are Server Tokens?

Server tokens are small pieces of information that your server sends in HTTP headers. They reveal details like:

  • The server type (Apache, Nginx, etc.)
  • The PHP version
  • The WordPress version

Hackers use this data to find vulnerabilities. If they see an outdated PHP version, for example, they might use known exploits to attack your website.

Hacker

Why Disable Server Tokens?

By disabling them, you make it harder for attackers to guess your setup. It’s a small but valuable step towards strengthening your site’s security.

How to Disable Server Tokens in WordPress

Let’s go through a few simple ways to disable server tokens.

1. Remove WordPress Version from Meta Tags

By default, WordPress adds a meta tag in your site’s header showing its version. To remove it:

<?php
remove_action('wp_head', 'wp_generator');
?>

Add this line to your functions.php file in your theme.

2. Disable PHP Version Exposure

PHP also reveals its version in the response headers. To disable this:

  1. Find your php.ini file.
  2. Look for this line:
    expose_php = On
  3. Change it to:
    expose_php = Off
  4. Save the file and restart your server.

This will hide your PHP version from prying eyes.

3. Hide Server Details in Apache or Nginx

Your server might also expose details about itself. You can prevent this.

For Apache:

  1. Edit the apache2.conf or httpd.conf file.
  2. Add these lines:
    ServerSignature Off
    ServerTokens Prod
        
  3. Save and restart Apache.

For Nginx:

  1. Edit the nginx.conf file.
  2. Add this line inside the http{} block:
    server_tokens off;
  3. Save the file and restart Nginx.

Bonus: Use a Security Plugin

If you’re not comfortable editing files, install a security plugin. Plugins like Wordfence or iThemes Security help hide this data without manual work.

Final Thoughts

Hiding server tokens won’t make your site 100% hack-proof, but it removes easy clues for attackers. Think of it like locking your doors—it’s one of many steps to stay safe.

Take a few minutes to apply these changes today. A little effort now can prevent big security problems later. Stay safe and keep your WordPress site secure!