How to change WP upload folder to subdomain

These are the steps to change your WordPress upload folder to subdomain. It is important that you make a backup WordPress site and WordPress database before attempting these steps.

1. Add a new subdomain e.g. using CPanel

Step 1: Add subdomain using CPanel

2. Copy all your files in the original “uploads” folder to the subdomain

You may use CPanel File Manager to copy the folder wp-content/uploads to

Step 2: CPanel File Manager to copy folder

3. Replace existing folder file path to new subdomain file path

Log in to CPanel and use phpMyAdmin to execute the following SQL commands.

Image file path in post content:

UPDATE wp_posts SET post_content = REPLACE(post_content,'','')

Attachment file path:

UPDATE wp_posts SET guid = REPLACE(guid,'','')

Note: replace the above domain and subdomain in the URL to your own.

4. Change the WordPress default upload folder to a custom upload folder in the subdomain

In order to change the default upload directory (Settings>Media) to a custom upload directory in the subdomain, you will need to edit the “upload path” field in the MySQL database. In phpMyAdmin, select the table “wp_options” and search for “upload” using LIKE %…% operator. The option_value for upload_path should be your server file path (e.g. /home/username/public_html/subdomain/uploads) and the upload_url_path is the URL to the subdomain upload folder.

Edit upload_path  and upload_url_path using phpMyAdmin


Leave a comment

Your email address will not be published.