Move Wp-Content Folder To Different Location

Ever since WordPress version 2.6 you can actually move your wp-content directory to a different location. The wp-content directory will store all your theme files, plugin files and images.

Why Move The wp-content Folder

The best reason to move the wp-content is for security if you move this to an unexpected location any hackers looking to target this area won't be able to find it, or it will make it more difficult to find.

To change the location of the wp-content is quite simple as the location of this folder can be configured in your wp-config.php file.

One thing to note is that you need to add these new constant variable above the line where WordPress includes the wp-settings.php.

// Add constant variables above this line

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

All you have to do is add a new variable WP_CONTENT_DIR and change the location of your wp-content folder.

define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/content/wp-content' );

To change the location of the wp-content URL there is another variable you can define in the wp-config.

define( 'WP_CONTENT_URL', 'http://www.paulund.co.uk/blog/content/wp-content' );

Moving Plugin Folder

If you don't want to change the location of the entire wp-content folder but just want to move the plugins folder then you can change this location the same as above.

For the plugin folder location we need to define the variable WP_PLUGIN_DIR.

define( 'WP_PLUGIN_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/content/wp-content/plugins' );

The same as the wp-content folder you can change the URL of the plugin folder for the variable WP_PLUGIN_URL.

define( 'WP_PLUGIN_URL', 'http://example/blog/content/wp-content/plugins');

The problem with doing this for plugins is that there is another variable which can be used by some plugin developers...PLUGINDIR. Therefore you need to make sure that you change this too.

define( 'PLUGINDIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/content/wp-content/plugins' );
Back to top ^

Join Paulund

  • Get access to 100s of premium tutorials and downloadable content
  • Members content consists of Premium WordPress plugins, CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
  • In-depth development tutorials
  • Priority tutorial requests
  • Priority email development support
  • No ads

Here at Paulund you'll find Web Development tutorials and snippets focusing mainly on PHP, WordPress and CSS. Members will get access to premium tutorials that go into more detail about development with these languages. You will also get access to downloadable premium content based on the tutorial.

Join Paulund

Leave a Reply

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