WordPress has a feature which gives you the ability to relocate and rename the “wp-content” directory that holds the themes, plugins and uploaded files used by your blog. Moving this directory is good from a security perspective too.
Here I will show how you can move the wp-content and plugins directory to a custom location on your web server. Update: From WordPress 3.5+, you can also change the default media upload location (instructions below), aka Uploads directory found inside wp-content.
Move WordPress wp-content directory
To move the wp-content directory, add the below two define()
directives to your WordPress wp-config.php
(configuration) file, replacing with appropriate paths on your server.
/* Move wp-content directory */ define('WP_CONTENT_DIR', 'new/path/to/wp-content'); // no host name, no trailing backslash define('WP_CONTENT_URL', '/url/to/wp-content');
The WP_CONTENT_DIR
, is used to specify the actual path of the content directory on your server, while the WP_CONTENT_URL
speficies the URL through which the contents inside the directory can be accessed.
If you are not sure about the exact path, here’s another way to define path using $_SERVER['DOCUMENT_ROOT']
and $_SERVER['SERVER_NAME']
global variable:
/* Move wp-content directory */ define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/content'); define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/content');
The $_SERVER['DOCUMENT_ROOT']
will construct a path relative to the document root, while $_SERVER['SERVER_NAME']
does the same for your web server.
Move WordPress Plugin Directory
If you want to move the WordPress plugins directory to a custom location, you have to define PLUGIN_DIR in your configuration file, similar to how CONTENT_DIR is defined for wp-content:
/* Move plugins directory */ define('WP_PLUGIN_DIR', 'new/path/to/plugins'); define('WP_PLUGIN_URL', '/url/to/plugins');
OR
/* Move plugins directory */ define('WP_PLUGIN_DIR', $_SERVER['DOCUMENT_ROOT'] . '/plugins' ); define('WP_PLUGIN_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/plugins');
Move WordPress Upload directory
To rename or move the upload directory anywhere within the wp-content directory you can use this code:
define( 'UPLOADS', 'wp-content/'.'files' );
Or, if you would like to move it to the root of your server, use this:
define( 'UPLOADS', ''.'uploads' );
Defining path to WordPress plugins folder may also help you resolve problems with those plugins that have a hardcoded path to wp-content.
If at any time you wish to go back to the original structure, simply delete the above added lines from wp-config.php
file and move back the folders to the original locations.
13 thoughts on “Move, Rename WordPress wp-content, Plugins & Uploads Directory”
Thanks a lot. Finally I got it working 😉 Thank you for helping out!
There’s another question. Maybe you can help out:
Is there any way to move only the theme’s folder out of wp-content to something like “www.mydomain.com/theme”?
If you had a solution thiat would be great!
Thx
Hi Steffen, glad it helped.
I couldn’t find a way to move the themes folder using only WordPress, but I guess you could use the Apache mod_rewrite functionality to rewrite requests referencing the old themes location to a new location. You need to restart or reload Apache for the changes to take effect, which may not be possible if you are on a shared host.
Ok. Unfortunatelly this is the case. Thank you very much anyway!
awesome saved my life 🙂
Glad it helped! 🙂
Thanks.
I am a beginner so please answer my question?
If you want to name my site and I think http://sumtips.com/ WP_CONTENT>> sumtips call my name I call PLUGIN>>> sumplugin code if possible, what I write and tell me exactly what code to call the first line or end line wp-config.php.
The names that I write the exact code please please please please please please me
Hey Jorji, I couldn’t understand one bit what you said there.
Hi,
I tried to use it on live wp ver.3.2.1 site, and it didn’t load. I can access admin, but for instance all media files are linked to wp-content folder source …
Can this be used on existing site ?
Thanks
Yes, it does work on WP 3.2.1 and also on existing website.
If your media files are not loading, check the website source to make sure where the links are actually pointing to. If links are hard coded and not dynamically generated, this method probably wont work. You’ll have to update those links manually in that case.
Hi Renji,
A great way to move&rename the wp-content folder, I only have one question.
(Noob here so it would be nice if you could enlighten some if it’s not to much asked)
Quote: Moving this directory is good from a security perspective too End quote
Correct me if I am wrong but by looking in sourcecode (by using Firefox for example) everyone can see where this folder is, so what benefit we have by renaming/moving this folder if it is about security?
Thanks in advance.
Is it possible to have multiple plugin directories? For example have wordpress check both the core plugin directory and also check a plugin directory inside a theme or child theme?
I want to rename “WP-Content” folder but I couldn’t find any resolution for this. I researched on Internet but didn’t found usefull articles. It doesn’t work with WordPress 3.X versions. It would be great if someone could tell me how to rename.
Can you explain the above code with example please ?