Next-Level Code. Nexuvibe Style ...

Hrs
Min
Sec
S3 Migration Strategy & WordPress Image URL Preservation Guide

Exit Strategy: How to Leave S3
Without Breaking 50,000 Image Links

Moving away from S3 after years of use is not as simple as copying files to a new destination. Tens of thousands of image URLs are embedded in post content, stored in the database, cached in CDN, and referenced by sitemaps and external links. This guide covers the complete migration without a single broken image.

13 min read
Updated 2026
Complete Migration Playbook
S3 to FTP migration strategy for WordPress showing how to move 50000 image links from AWS S3 to new CDN domain without breaking any image URLs in posts pages or external links

Migrating away from AWS S3 after years of use is one of the more technically demanding operations in WordPress infrastructure management. It is not like changing hosting providers, where you move files and update DNS. With S3, the complication is that image URLs are embedded throughout your content. Every post that contains an image, every page with a featured image, every WooCommerce product with gallery photos contains direct S3 bucket URLs or CloudFront distribution URLs referencing your specific bucket.

A site with three years of content and 1,000 products might have 50,000 or more individual image URLs stored in its database, embedded in post content via Gutenberg block JSON, referenced in page builder data stored in postmeta, and included in sitemap XML files that have been indexed by search engines. Moving the files to FTP is straightforward. Making all those URLs point to the new CDN domain without a single broken image during or after the migration is where the real complexity lies.

This guide is the definitive migration playbook for this specific scenario. It covers every location where S3 URLs are stored, the order in which to address them, the tools and commands for each step, and the verification process that confirms zero broken images before you shut down S3. It is the guide that should have existed when you set up S3, explaining how you would leave if you ever needed to.

What this migration playbook covers
→A complete inventory of every location where S3 URLs are stored in a WordPress database.
→The three migration strategies and which one is right for your situation.
→The step-by-step migration sequence with exact WP-CLI commands.
→How to handle Gutenberg block JSON and page builder serialized data during URL replacement.
→The S3 redirect setup that keeps external links working after migration.
→The verification checklist to confirm zero broken images before S3 shutdown.

A complete inventory of where S3 URLs live in WordPress

Before beginning any migration, you need to understand every location in your WordPress database where S3 URLs are stored. Missing even one location results in broken images after the migration. This inventory is the foundation of a complete migration.

Location 1: wp_posts — post_content column

Every image inserted into post or page content contains its full URL in the post_content column. In classic editor posts, these appear as standard img src attributes. In Gutenberg posts, they appear inside block JSON within the post_content as both “url” values and as part of the HTML embedded in the block markup. This is the largest concentration of S3 URLs.

— Count S3 URL occurrences in post content
SELECT COUNT(*) FROM wp_posts
WHERE post_content LIKE ‘%s3.amazonaws.com%’
OR post_content LIKE ‘%your-bucket-name%’;

Location 2: wp_postmeta — _thumbnail_id and _wp_attachment_metadata

Featured images are stored as attachment IDs in _thumbnail_id, not as URLs — so these do not need URL replacement. However, _wp_attachment_metadata stores the file paths and S3 URLs for each attachment’s source file and thumbnails. WP Offload Media stores additional metadata including the S3 bucket and path here. This metadata drives WP FTP Media’s URL rewriting after migration.

— Check attachment metadata for S3 references
SELECT COUNT(*) FROM wp_postmeta
WHERE meta_key = ‘_wp_attachment_metadata’
AND meta_value LIKE ‘%amazonaws%’;

Location 3: wp_options — theme customizer, widget data, and plugin settings

The wp_options table stores theme customizer settings (header images, background images, logo URLs), widget content that may include images, WooCommerce settings that reference images, and various plugin settings. Many of these contain absolute URLs to S3-hosted images that were set years ago and forgotten.

SELECT option_name FROM wp_options
WHERE option_value LIKE ‘%s3.amazonaws.com%’
OR option_value LIKE ‘%cloudfront.net%’;

Location 4: wp_postmeta — page builder data (Elementor, Divi, WPBakery)

Page builders store their layout and content data in wp_postmeta, often as serialized PHP arrays or JSON strings. These data structures contain image URLs embedded within nested data. Standard database search-and-replace tools handle this correctly if they understand serialized data structure — tools that do not understand serialization will corrupt the data.

SELECT COUNT(*) FROM wp_postmeta
WHERE meta_key LIKE ‘_elementor%’
AND meta_value LIKE ‘%amazonaws%’;

Location 5: wp_posts — guid column

The guid column in wp_posts stores the permanent URL for each attachment. WP Offload Media typically sets the guid to the S3 URL. While WordPress does not use the guid for frontend display (it uses attachment metadata and URL rewriting instead), some plugins and caching systems reference the guid. Updating the guid to the new CDN URL during migration ensures consistency.

🔗For large WordPress sites, a WordPress media offload migration can reduce downtime from hours to mere minutes by decoupling file transfers from database operations. →

Location 6: External — sitemaps, external links, and cached CDN

S3 or CloudFront URLs may be present in XML sitemaps that have been indexed by search engines, in external sites that have linked directly to your images, in email newsletters that were sent containing S3 image links, and in CDN caches that will eventually expire but show old URLs until they do. These external references cannot be changed from within WordPress — they require either permanent S3 redirects or acceptance that old external links will eventually break as S3 is shut down.

The three migration strategies: choosing the right approach

Three approaches are available for migrating from S3 to FTP. They differ in how they handle the URL transition and what they require from the database.

Strategy A: Custom CDN domain (recommended)
Best for most sites

Point your CDN to the FTP server. Create a custom subdomain for image delivery (e.g., cdn.yoursite.com). Configure WP FTP Media to use this custom CDN domain. Perform a database search-and-replace from the old S3/CloudFront URL to the new CDN domain. Because you own cdn.yoursite.com, you can later change what it points to (different CDN, different storage) without another database replacement.

Requirements: Custom subdomain configured in DNS, CDN pull zone setup, one database search-and-replace.
Zero broken images if: The custom CDN domain is configured and serving images from FTP before the database replacement is run.

Strategy B: S3 URL redirect (zero database changes)
Safest for large sites

Configure the S3 bucket to redirect all requests to the new CDN URL. All existing S3 URLs continue to work because they redirect 301 to the corresponding CDN URL. No database changes are needed. WP FTP Media handles new uploads going forward. Old content keeps serving correctly via redirect. The S3 bucket must remain active for as long as the redirects need to function.

Requirements: S3 bucket stays active (but can be empty with just a redirect rule). AWS Route 53 or S3 static website hosting for redirect configuration.
Limitation: S3 costs continue as long as redirects are needed. Not suitable for complete S3 shutdown.

Strategy C: WP FTP Media URL rewriting only (no database replacement)
Fastest to implement

WP FTP Media rewrites all image URLs at render time. Configure it with the old S3 domain as the “from” domain and the new CDN domain as the “to” domain. Every page render automatically outputs CDN URLs regardless of what is stored in the database. The S3 URLs remain in the database but are never exposed to browsers. This is the fastest strategy but requires that WP FTP Media is always active for the rewriting to function.

Requirements: WP FTP Media installed and active. Files transferred to FTP.
Risk: If WP FTP Media is ever deactivated, all images break immediately. Database cleanup recommended as a follow-up step.

The step-by-step migration sequence

The following sequence uses Strategy A (custom CDN domain) which is recommended for most sites conducting a complete S3 exit. Each step must be completed in order.

1
Take a complete database backup and verify it

This is non-negotiable. Export the full database to a SQL file, store it offsite, and test the restore on a staging environment before proceeding. The database search-and-replace in Step 6 is irreversible on the live database without this backup.

🔗Many store owners overlook WooCommerce S3 egress fee risks until unexpected charges accumulate from high-traffic product image deliveries. →

2
Set up FTP storage, CDN, and custom CDN subdomain

Create the Hetzner Storage Box or equivalent FTP account. Set up a BunnyCDN or Cloudflare pull zone. Configure a custom CNAME record: cdn.yoursite.com pointing to the CDN zone’s hostname. Verify the CDN URL resolves correctly by uploading a test image to FTP and confirming it loads from cdn.yoursite.com/test-image.jpg before proceeding.

3
Download all files from S3 and upload to FTP

Use the AWS CLI to sync the S3 bucket to a local directory, then upload from local to FTP via rsync or FileZilla. Preserve the exact directory structure — the paths must be identical on FTP to what they were on S3 for the URL rewriting to work correctly. For a large library, this step may run overnight.

aws s3 sync s3://your-bucket-name ./local-backup/
rsync -avz ./local-backup/ [email protected]:/uploads/

4
Install WP FTP Media and configure with URL rewriting pointing to old S3 domain

Install WP FTP Media. Configure the FTP connection pointing to your new FTP server. Set the CDN base URL to cdn.yoursite.com. At this point, enable WP FTP Media’s URL rewriting to replace the old S3/CloudFront domain with cdn.yoursite.com in all rendered output. Test several posts and product pages to verify images now load from cdn.yoursite.com using files served from the FTP server.

5
Run the database search-and-replace on staging first

Before running on production, clone the production database to staging and run the full search-and-replace on staging. Verify staging renders all images correctly. This confirms the replacement logic is correct and handles serialized data in page builder postmeta without corruption.

# WP-CLI search-replace handles serialized data correctly
wp search-replace ‘https://your-bucket.s3.amazonaws.com’
‘https://cdn.yoursite.com’ –all-tables –report

6
Run the database search-and-replace on production during low-traffic window

With the staging verification complete, run the same WP-CLI command on production. For a site with 50,000 image references across 1,000 posts, this command typically completes in 30 to 90 seconds. WP-CLI’s search-replace handles serialized data, JSON, and standard text across all tables. Replace the old S3 URL, old CloudFront URL (if used), and any http variants of both.

7
Deactivate WP Offload Media and verify images still load

After the database replacement, the database contains CDN URLs directly. Deactivate WP Offload Media. Images should still load because they are now pointing to cdn.yoursite.com in the database and WP FTP Media handles new uploads going forward. If any images break after deactivating WP Offload Media, there are URL patterns that were not caught by the search-and-replace — investigate those URLs and run targeted replacements.

🔗After migrating from S3, implementing global CDN media delivery for WordPress ensures faster load times across all regions without broken image links. →

Setting up S3 redirects for external links

Even after a perfect internal migration, external references to your S3 images persist. Blog posts on other sites that have embedded your images. Social media posts that contain direct S3 image links. Email newsletters sent over the years. These cannot be updated. The only option is to configure S3 to redirect these requests to the new CDN URL before shutting down the bucket.

S3 bucket redirect rule configuration (AWS S3 console — Static Website Hosting)
[
  {
    “Condition”: {},
    “Redirect”: {
      “Protocol”: “https”,
      “HostName”: “cdn.yoursite.com”,
      “HttpRedirectCode”: “301”
    }
  }
]

With this redirect rule configured, any request to your S3 bucket (whether through the S3 URL directly or through CloudFront if it is still pointing to the bucket) will 301 redirect to the corresponding path on cdn.yoursite.com. Because the redirect preserves the path, an old S3 URL for /wp-content/uploads/2023/product.jpg redirects to cdn.yoursite.com/wp-content/uploads/2023/product.jpg — which is exactly where the file now lives on the FTP server. Leave these redirects in place for 12 to 18 months to capture the long tail of external references before shutting down the bucket entirely.

The verification checklist: confirming zero broken images

Check 1: Database residual S3 URLs
SELECT COUNT(*) FROM wp_posts WHERE post_content LIKE ‘%s3.amazonaws.com%’;
— Target: 0

Check 2: Browser DevTools network tab

Open 10 different post types (post, page, product, category, home page) in Chrome DevTools. Filter the Network tab by “Img”. Verify all image requests go to cdn.yoursite.com. No requests should go to s3.amazonaws.com or your CloudFront distribution domain.

Check 3: Crawl with a broken link checker

Run Screaming Frog or a similar crawler across the entire site specifically checking image URLs. Any 404 responses from cdn.yoursite.com indicate files that exist in the database but were not transferred to FTP during Step 3. Download missing files from S3 (which still has the originals) and upload them to FTP.

🔗For sites handling massive media libraries, switching to a self-hosted high-volume image delivery solution can eliminate dependency on S3 while maintaining performance. →

Check 4: WooCommerce checkout and order emails

Place a test order and check the order confirmation email. Product images in WooCommerce emails are often rendered server-side from the postmeta data at send time. Verify that product thumbnails in the order confirmation email show correctly from the CDN domain. WooCommerce order emails are a commonly missed location for broken images post-migration.

Check 5: Google Search Console

After migration, monitor the Google Search Console Enhancement report and the Core Web Vitals report for 4 to 6 weeks. Image indexing should transition from the S3 domain to the CDN domain over this period as Google recrawls pages. A spike in crawl errors in the S3 redirect period confirms that Google is finding and following the 301 redirects correctly.

According to the official WP-CLI documentation for the search-replace command, the –all-tables flag and correct handling of serialized data are critical for WordPress migrations involving URL replacement. The documentation explicitly warns against using simple SQL UPDATE statements for URL replacement in WordPress because they do not handle PHP serialized arrays correctly — the same PHP-serialized data that page builders and WooCommerce use to store their content.

A complete S3 exit is a significant infrastructure operation but a fully manageable one when approached with the right sequence and verification steps. WP FTP Media’s comprehensive WordPress S3 exit and FTP migration plugin is the destination infrastructure that makes leaving S3 worthwhile: the same CDN-delivered, flat-rate-priced, inode-unconstrained media architecture that this entire guide series has been building toward — now with a clear, verified, zero-broken-image migration path to reach it.


WP FTP Media monitor showing healthy FTP connection post S3 migration with all WordPress images serving from CDN on new domain confirming successful S3 exit with zero broken links

Post-S3-exit health in WP FTP Media – WordPress complete S3 to FTP migration plugin with URL replacement for exiting AWS S3 and serving all image links from new CDN domain without broken references — healthy FTP connection, CDN serving all images, S3 bucket scheduled for shutdown: the exit is complete.
Zero Broken Images · Complete S3 Exit · FTP + CDN Forever After

50,000 image links. One migration. Zero broken images. Your S3 days are done.

WP FTP Media is the destination for your S3 migration: flat-rate FTP storage, CDN delivery, no egress fees, and the URL rewriting infrastructure that makes a complete database transition from S3 domain to your own CDN subdomain clean, verified, and permanent.

WP FTP Media – WordPress S3 exit migration plugin for moving 50000 image links from AWS S3 to FTP storage with CDN delivery and complete database URL replacement without broken images

WP FTP Media by NEXU WP
WordPress plugin · S3 Migration Ready · FTP & SFTP · CDN Delivery


Get WP FTP Media

Picture of Mahdi Jabinpour

Mahdi Jabinpour

As a sales-driven developer and the founder of NexuWP, Mahdi focuses on building WordPress solutions that don't just work—they convert. From AI-powered bulk translation engines to high-efficiency media offloading, he helps business owners automate the "grind" so they can focus on global growth. He is a pioneer in integrating advanced LLMs into the WordPress workflow.

RELATED POSTS

RELATED POSTS

4 Reviews
David Garcia 5 months ago

This saved my site's pics totally worth it!

Mahdi Jabinpour 5 months ago

Thank you.

John Jackson 6 months ago

This guide saved me weeks of headaches when moving my business site off S3. the step by step on handling Gutenberg block JSON and serialized data? Absolute lifesaver I had no idea how buried those old URLs were in my posts. worth every penny just for the stress it saved me.

Mahdi Jabinpour 6 months ago

This guide was written with challenges like those hidden Gutenberg URLs in mind they've stumped even seasoned developers. we're

Elizabeth Anderson 7 months ago

I bought this guide hoping it would address the nightmare of Gutenberg block JSON and page builder serialized data during URL replacement, but it barely scratches the surface. the section on handling embedded URLs in post content is so vague it might as well not exist

Elizabeth Williams 8 months ago

Hey everyone! just finished migrating my WordPress site away from S3 using this guide, and wow I had no idea how many hidden image URLs were lurking in my database. Like, tens of thousands embedded in old posts, cached in CDN, even referenced in sitemaps

Please log in to leave a review.