Let's migrate your current WordPress media uploads files to another domain. A specific sub-domain will make your images load faster (if configured properly) and be shorter file names too.
Default WordPress Media Settings
- https://von.enterprises/help/wp-content/uploads (upload path)
- http://vondelphia.com/files/logo.png (file name)
New WordPress Media Settings
- https://files.von.enterprises (upload path)
- http://vondelphia.com/files/logo.png (file name)
Let's remove and replace help/files/
from all uploaded media with files
and of course, migrate / transfer files to the new subdomain. It's important that all new uploaded images are automatically moved to the subdomain too!
- Install and Activate two plugins
- Search & Replace – global search and replace in database to call new “updated pretty” image links.
- WP Original Media Path – customize media path for uploaded files in WordPress
- Create a backup of your database by clicking “Create SQL File” in the Search & Replace Plugin Admin (under Tools menu)
- Search & Replace your default upload domain to your new domain path with Dry Run and confirm that it's to your likings, than uncheck Dry Run and click Save changes to Database and click Do Search & Replace.
- in our example, we wanted to change
help/wp-content/uploads
tofiles
.
- in our example, we wanted to change
- After you deactivate Search & Replace, navigate to WP Original Media Path under Settings and check Expert mode.
- this is the “long path” to your subdomain directory that you can find in your cPanel file manager or FTP client URL BAR… it might look something like
/home/primarydomain/public_html/files.yourdomain.com
.
- this is the “long path” to your subdomain directory that you can find in your cPanel file manager or FTP client URL BAR… it might look something like
- In the Full URL path to files field, just specify the url for your upload folder and click Save Changes.
- Goto your Media Library and test upload a file, everything will work perfectly (even Thumbnail generated images work during upload). Using your sFTP Client, visit your subdomain directory and you'll notice files are being uploaded accordingly. IF NOT, just check your file permissions.
Sources
- Upload images to remote server
- Wordpress: Upload images to remote server
- upload images to subdomain