How to replace and rename your wp-content folder

By default, every WordPress installation will contain the same core files with the same names and the same locations. While this is a good solution for developers, who can easily navigate through their themes and plugins to get specific content, at the same this is a huge security risk. If someone decides to access your core files, which include your WP-Content folder where all theme, plugin, and uploaded files are, he would already know the path to your stuff.

In one of our previous articles, we showed you how to hide the entire folder or its subfolder from curious people. Instead of simply hiding your folder, you may want to think about relocating it or even renaming the entire folder.

IMPORTANT: Before you do any changes to wp-config.php file, make sure that you create a backup of the file just in case something goes wrong. When the backup is ready, you can go on and move your wp-content folder on to another location:

Relocate wp-content folder:

  1. Open wp-config.php
  2. Navigate to the following line of code (usually found on the bottom of the file):
  3. require_once(ABSPATH . 'wp-settings.php');
  4. Copy and paste the following code above that line:
  5. define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . 'new-path/wp-content' );
    define( 'WP_CONTENT_URL', 'http://dev.firstsiteguide.com/new-path/wp-content' );
  6. Change location to any location you would like
  7. Save changes

Rename wp-content folder:

If you want to rename your wp-content folder, you can do that with the following code which needs to be added in wp-config.php as well:

  1. Open wp-config.php
  2. Navigate to the following line of code (usually found on the bottom of the file):
  3. require_once(ABSPATH . 'wp-settings.php');
  4. Copy and paste the following code above aforementioned line:
  5. define ('WP_CONTENT_FOLDERNAME', 'newfoldername');
  6. Rename folder
  7. Save changes


The changes you have made in the wp-config.php file only tell WordPress where to look for your wp-content directory. If you go on and check your media files, for example, you will see that all images you already have are linking to the new directory. To make everything work correctly, make sure that you physically move the directory into a new location which you have defined in the code above.

While all these changes will make your site more secure, be careful if doing so; making the changes may stop your themes and plugins from working, so make the changes only if you’re sure you can move the folder without getting into problems.

If you found this article useful, don’t forget to check out and learn more about WordPress.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

One thought on “How to replace and rename your wp-content folder

Leave a Reply

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