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. static.myblogsg.com 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 static.myblogsg.com/uploads
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,'https://myblogsg.com/wp-content/uploads','https://static.myblogsg.com/uploads')
Attachment file path:
UPDATE wp_posts SET guid = REPLACE(guid,'https://myblogsg.com/wp-content/uploads','https://static.myblogsg.com/uploads')
Note: replace the above domain and subdomain in the URL to your own.
4. Change upload_path and upload_url_path.
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.