How to Replace or Rename Your WP-Content Folder

WordPress has slowly become one of the most used CMS over the internet. The downside of that is most of the sites on the web follows the same structure, and one loophole can expose all those sites to a security threat.

Every #webmaster should take some actions to make sure that their site is secure. One of the action is to make sure that your #site structure is hidden so that #hackers can’t quickly figure it out. Click To Tweet

WP-Content Folder

WordPress has some predefined folder structure which helps in segregating content. Each folder has a specific purpose, and it contains a particular type of data.

One of that folder is WP-Content which contains your themes, plugin and uploaded images. More specifically, all the user content related to specific WordPress site is kept in that folder.

You can recover from the loss of any other folder, but if you lose WP-Content folder, it will be hard to recover unless you have a backup.

So you need to make sure that you take the backup of your WordPress site regularly and hide the WP-Content folder so that it’s not easy to find.

WP-Config File

WP-Config.php is one of the important files for WordPress, which contains essential settings about your site structure like your database connection details, your site address, etc. Because of that, you want to make sure that the file is always protected. One of Security Ninja’s tests will let you know if this file has right permisions, so don’t forget to scan your site every now and then.

There are few settings which can help you replace or rename the WP-Content folder. Most of the hackers just run some automated scripts to hack the sites, and those scripts will fail in case your site structure is different than the regular WordPress site.

You can find the WP-Config.php file in your site home directory. The best way to update it is by downloading it to your computer, make a change and upload it back to your server.


You can use any FTP client to download and upload the WP-Config.php file.

Most of the entries in WP-Config file start with a keyword – define.


It allows you to define values which can be accessed from your WordPress installation.

Syntax – define(Symbol1, Value1)

Symbol1 – name which you can use anywhere in WordPress installation

Value1 – Value which will be replaced for Symbol1

WordPress has some predefined symbols with default values which are used to setup installation defaults. You can use and replace those default values to accomplish your task.

How to Rename WP-Content Folder

If you do not want your user content folder to be named as WP-Content, you can change the name of the folder and ask WordPress to pick your user data from the new folder.

WordPress allows you to define the name of the content folder with the help of WP_CONTENT_FOLDERNAME symbol.

Step 1: Download the WP-Config.php file

Step 2: Open and Edit the WP-Config.php file to add the below line

define( 'WP_CONTENT_FOLDERNAME', ‘new_directry_name’ );

You can add the code before the ABSPATH variable declaration in WP-Config.php.


Once you add this to your WP-Config.php, WordPress will treat the new directory name as your content folder.

Remember this is just a rename, so your new content directory should be in the same location as WP-Content folder.

Step 3: Change ‘new_directory_name’ to the name you want for your content folder.

Step 4: Upload WP-Config.php file back to your server.

How to replace the WP-Content Folder

If you want to replace the wp-content folder rather than renaming it in the same place, you need to use the below mention method.

WordPress comes with two symbols, WP_CONTENT_DIR and WP_CONTENT_URL, which allows you to define your content directory and content URL structure.

Step 1: Download the WP-Config.php file

Step 2: Open and Edit the WP-Config.php file to add the below lines

define( 'WP_CONTENT_DIR', ‘new_directry_local_path’ );
define( 'WP_CONTENT_URL', 'http://new_directry_url' );

WP_CONTENT_DIR will tell WordPress to use the specified directory as a content directory rather than WP-Content directory.

You also need to change the WP_CONTENT_URL, so that the URL also points to correct place. It is crucial for your themes, plugins, and attachments to work correctly.

Like in rename method, you can add these line before the ABSPATH variable declarations.


Make sure there are no forward slashes (/) at the end of URL and Directory.

Step 3: Change new_directory_local_path and http://new_directory_url to your local path and URL.

Step 4: Upload WP-Config.php file back to your server.

Once you add these lines, you will see all your uploaded themes, plugins and images will start using the new directory rather than a WP-Content folder.

So, here is how you can rename or replace the WP-Content folder to provide more security to your WordPress site. This will help in making sure that hackers scripts can’t directly run on your installation, which will avoid many automated attacks on your WordPress site. So go ahead and secure your WordPress installation.

Join our email list

Interesting articles about

WordPress and internet security

5 thoughts on “How to Replace or Rename Your WP-Content Folder”

  1. John Mulder

    Thanks for the info. How does this affect any future updates on WordPress?

    Kind regards,

  2. Lars Koudal

    Hi John

    WordPress is pretty good in being backward compatible, and in my experience, this can work. However, some plugins and themes are sometimes not properly set up for changing your local paths so your experience might vary.

  3. Hi, I tried to follow your tutorial. but when I go to click the link of the document it tells me:
    – The theme directory “finacia” does not exist.
    – ERROR: The themes directory is either empty or doesn’t exist. Please check your installation
    Is the code I entered correct?
    define (‘WP_CONTENT_DIR’, ‘allegati’);
    define (‘WP_CONTENT_URL’, ‘http://mysite.it/allegati’);

  4. Hello Marco

    Make sure after you change the “wp-content” folder to “allegati” you have your theme in the right folder.
    Usual path would be : “wp-content/themes/financia/” – when you changed the folder, it looks for the theme in “allegati/themes/financia/” – Please make sure that folder exists?

  5. Hi

    This worked however WordPress would keep recreating wp-content folder whenever I uploaded an image through Media Library. I fixed this in:
    – Settings, Media, updating file path in “Store uploads in this folder”


Leave a Comment

Your email address will not be published. Required fields are marked *

Safe, Simple & Secure

WordPress Security made easy

Powerful, yet easy to use

Keep your website safe & prevent downtime due to security issues.

custom logoWP Security NinjaWP Security Ninja
5 Stars - Based on 80 User Reviews

We handle your WordPress security

We are PayPal verified.

20% OFF

Subscribe to our newsletter

* We do not spam or share your email

Discount on any Security Ninja plan

and get

Hi and welcome back :-)