WordPress Security
WordPress Security
Posted By Gregory

Get WordPress protected: rename the plugins folder


Giving the plugins folder a new name is one of the most underestimated ways that make your WordPress protection stronger. And yet it’s free and easy.

Why it matters and how it works

According to our studies at Cerber Lab most hacker attacks and attempts to exploit plugin vulnerabilities assume that all WordPress plugins are located in the default folder for all plugins which is /wp-content/plugins/. Fortunately, the name of this folder can be easily changed to whatever you want in literally two simple steps. Does this mean that cybercriminals have zero knowledge about the ability to rename the folder and blindly attack the default plugin location? No, not always, but, the vast majority of WordPress powered websites use the default folder structure, and that’s why cybercriminals exploit this weakness with easy.

Our analytics shows that most websites are hacked by exploiting a vulnerability in an outdated plugin and in most cases the attacker has used the vulnerability in the PHP file that is located in the default WordPress plugins folder.

Hint: use the Cerber malware scanner to find a vulnerability in installed plugins.

How to rename the WordPress plugins folder

First of all, you need to have access to the files on your website via your hosting control panel which usually has a file manager. Alternatively, you can use an FTP client.

The first step is to rename the existing WordPress plugins folder to any name you want. Let’s assume we use the modules name. Note that the name of the plugins folder must contain ASCII characters only. Simply put “use Latin alphabet letters only”.

The second step is adding two define directives to the wp-config.php file which help WordPress to recognize and use the new name of the plugins folder. You may not use a built-in file editor in the WordPress admin dashboard at this step. Use a file editor from within your hosting control panel or an FTP client to edit the wp-config.php file. See an example below and note:

  • You have to add directives to the beginning of the file on the next line after <?php.
  • You have to use your full path to your plugins directory for WP_PLUGIN_DIR. Hint: You can find the full path to the standard plugins folder on the Tools / Diagnostic admin page. It’s shown in the Filesystem section in the “WordPress plugins folder” row.
  • No trailing slashes.
<?php

define('WP_PLUGIN_DIR', '/full/path/to/wp-content/modules');
define('WP_PLUGIN_URL', 'https://example.com/wp-content/modules');

The WP_PLUGIN_DIR constant defines the full path without trailing slash to your renamed plugins folder.

The WP_PLUGIN_URL constant defines the URL without trailing slash of your renamed plugins folder.

Once you’ve completed these two steps, you add an additional security layer to your WordPress. Another security mechanism you should consider is enabling scheduled malware scans.

Possible issues and troubleshooting

The website is not loading and showing errors. It usually means you’ve made a typo in the folder name. Carefully check the definitions that you’ve added to wp-config.php, the full path, and the URL you’ve specified. You have to specify the path and the URL of your website. Do not copy them from the example above and do not try to rename the plugin folder or edit the wp-config.php file from within the WordPress dashboard.

Some features stopped working. You happen to have a poorly designed or outdated plugin installed on the website. The best thing you can do is to get rid of it. There are no excuses for poor plugin development. A plugin developer must obey WordPress coding standards.

How to restore the default name of the plugins folder

  1. Remove all lines with WP_PLUGIN_DIR  and WP_PLUGIN_URL directives from the wp-config.php file
  2. The default name of the folder where WordPress plugins reside is plugins so rename the plugin folder back to plugins

Next steps that’ll strengthen your WordPress security

Have any questions?

If you have a question regarding WordPress security or WP Cerber, leave them in the comments section below or get them answered on the community forum.

Spotted a bug or glitch?

We’d love to fix it! Share your bug discoveries with us here: Bug Report.


I'm a software engineer and team lead at Cerber Tech. I started coding in 1993 on IBM System/370 and today software engineering at Cerber Tech is how I make my living.

View Comments

Leave a Reply to Jim
Cancel Reply