Change the Default Upload Images Path in WordPress from wp-uploads to folder in your public_html root WordPress Installation
If you would like to change the default upload media files folder with your own name and place in your website and WordPress Installation you can add the snippet below when you add manually your details for MYSQL username, database username, and database password in wp-config.php
Where to add the snippet code in wp-config.php to change your default images, videos and files upload path in your WordPress website?
You must add the snippet below right after the code on line 80 define( ‘WP_DEBUG’, false ); in your wp-config.php
Add the snippet below to change your file upload path with your own short name
define( ‘UPLOADS’, ”.’img’ );
- Note* To get this new media upload path you must create a new folder in your root Installation WordPress in the public_html or www or whatever is your root directory and your WordPress website installation.
- Note** Do not use this on live sites because will cause an issue with all your current uploads, images, videos, and files.
- Note*** If you do this by mistake just copy and move your current media folders from the default WordPress upload folder /wp-content/uploads and move all folders and image files to the new folder in your root dir.
Why change the Default Upload Images Path in WordPress?
If you need a bit more speed, clean URLs for your images, videos, files changing the default upload path for your WordPress website will give you a better and clean URL structure for your media and will remove the /wp-content/uploads/year/month/file.jpg long URLs which will speed up the server requests for bot crawlers and your visitors as well. Google always mention that short and clean URLs for your pages, media, and scripts are better for your websites instead of long URLs and deep level folders.
Example how your media files will look after changing the default WordPress upload path with a new one close to your root domain folder
- The default url structure is like the example url below
- Before: https://yourdomain.com/wp-content/uploads/year/month/file.jpg – 5 levels deep folder to your final image
- The new url structure after change your default upload path directory will be like the example URL below
- When you change your default upload path with the snippet from this Tutorial your media files will have a short url structure and they will do less server request to the root folder instead of 3 folder structure for media URLs by default in your WordPress Installation root folder
- After: https://yourdomain.com/img/year/month/file.jpg – 4 levels deep folder to your final image