≡ Menu

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. static.myblogsg.com 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 static.myblogsg.com/uploads

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,'http://myblogsg.com/wp-content/uploads','http://static.myblogsg.com/uploads')

Attachment file path:

UPDATE wp_posts SET guid = REPLACE(guid,'http://myblogsg.com/wp-content/uploads','http://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.

Edit upload_path  and upload_url_path using phpMyAdmin

Reference:
http://www.dezzain.com/wordpress-tutorials/how-to-move-wordpress-uploads-path-to-subdomain/

{ 0 comments… add one }

Leave a Comment