When you add new videos and images to WordPress, they are stored in a default “uploads” folder with a certain URL structure consisting of month and year based folder organization. If you go to “Settings -> Media” in the latest versions of WordPress, you can see the checkbox allowing you to configure this option.
However before WordPress 3.8, it also allowed you to select the directory in which you wanted WordPress to upload the media files. They removed it because it wasn’t being used much and also because accidentally changing the file upload folder can have disastrous consequences for your blog media!
But there are often valid reasons to make this change. Some people prefer to host their media content in a subdomain or perhaps just to add a little bit of obscurity to the normally predictable WordPress URLs so that it makes it more difficult for people to access your uploads folder willy-nilly. For these reasons, WordPress still allows us to define the location of the uploads folder relative to the blog path, but we need to specify it in the wp-config.php file instead. Here’s how.
Changing the Upload Location
The default location of our media files is “wp-content/uploads” where “wp-content” is located in the root of your WordPress installation. You can see in the screenshot below that images I’ve already uploaded have this kind of directory structure:
In this example, I’m going to move the folder out of wp-content and into the WordPress root. We can modify this if we want and simply change the directory name of “uploads” to something else as well. Open up your WordPress installation location via FTP and in the root directory of the application, right-click and modify the wp-config.php file like this:
As you scroll down the contents of wp-config.php, you see a number of “define” statements which specify the values of certain variables in capital letters. Underneath one of these on a new separate line, paste in the following:
define( 'UPLOADS', 'files' );
This defines a variable called “UPLOADS”. The value is relative to the blog root directory. So when we assign it the value “files”, it means the folder called “files” is in the main WordPress folder, sharing the same level with others like “wp-content” and “wp-includes”. Replace this with whatever directory you want to put your media in. If for example, you simply want to rename the “uploads” folder, use this code instead:
define( 'UPLOADS', 'wp-content/files' );
This effectively changes the name of “uploads” to “files”. Note how there’s no starting slash – an important thing to remember. Once you save the changes to wp-config.php, reload your “Media” folder. You should see something like this:
As expected, all your existing media uploads are broken since they’re still pointing to the old location.
p style=”text-align: center;”>
To fix this, you have to copy or move everything in the old folder to the new one, while maintaining the same directory structure.
Also, you’re probably going to have to change the URLs of all linked images from your blog posts. Its’ easier to do that with a plugin that directly manipulates the database. You can see how to do that with my earlier tutorial here. From now on whenever you insert new media into WordPress, it will assign it to the new upload location as shown here:
Changing your media upload location might help you achieve the URL consistency you’re looking for and also may allow you to take advantage of some pagespeed benefits from sub-domains. However it’s not a smart security tactic by itself, though it can serve some specific purposes.
Read WordPress Hosting Reviews