The Ultimate Guide: Migrating Shopify URLs to Headless Storefronts
Don't lose your SEO juice. Learn how to map thousands of product URLs to your new Next.js or Hydrogen frontend using bulk redirects. We cover CSV exports, regex patterns, and verification strategies.

Why Migration is Critical
When you replatform from Shopify Liquid to a headless architecture (like Next.js or Hydrogen), your URL structure almost always changes.
Shopify enforces a rigid structure:
/products/{handle}/collections/{handle}/pages/{handle}
But in a custom Next.js app, you might want cleaner, shorter URLs for better SEO and user experience:
/shop/{handle}/c/{handle}/{handle}
The SEO Risk
Without a comprehensive 301 Redirect Strategy, launching your new headless site is SEO suicide.
- 404 Errors: Googlebot will hit dead ends for all your old indexed pages.
- Link Juice Loss: Backlinks from blogs, social media, and ads will break.
- Revenue Drop: Users following old bookmarks or email links will bounce immediately.
[!WARNING] A drop in traffic of 40-60% is common for migrations that launch without a redirect map.
Step 1: Exporting Your Legacy URLs
Before you write a single line of code, you need a complete map of your existing site.
Method A: Shopify Admin (Simple)
Go to Products > Export and choose "All products". This gives you a CSV with a Handle column.
Handle,Title,Variant Price
cool-tshirt,Cool T-Shirt,29.99
blue-jeans,Blue Jeans,49.99Method B: Sitemap Parsing (Thorough)
For a complete list including blogs and pages, parse your sitemap.xml.
# Install a sitemap parser
npm install -g sitemap-to-csv
# Fetch and convert
sitemap-to-csv https://your-shopify-store.com/sitemap.xml > urls.csvStep 2: Designing the Redirect Strategy
You rarely need to map URLs 1-to-1. The power of Regex (Regular Expressions) allows you to handle thousands of SKUs with a single rule.
Scenario A: Simple Prefix Change
Old: https://store.com/products/blue-jeans
New: https://store.com/shop/blue-jeans
UrlEdge Rule:
- Source:
^/products/(.*)$ - Destination:
/shop/$1 - Type: 301 (Permanent)
Scenario B: Removing Prefixes (Risky but Clean)
Old: https://store.com/products/blue-jeans
New: https://store.com/blue-jeans
UrlEdge Rule:
- Source:
^/products/(.*)$ - Destination:
/$1
[!TIP] Be careful with root-level URLs. Ensure your new router doesn't conflict with
/about,/contact, or/cart.
Step 3: Implementation at the Edge
Why handle redirects at the Edge instead of in your Next.js app?

The Latency Problem
If you handle redirects in next.config.js or Middleware, the request has to hit your origin server (Vercel/Node.js), spin up a compute instance, match the rule, and respond.
| Method | Latency (p95) | Infrastructure |
|---|---|---|
| Shopify Native | 120ms | Shopify Core |
| Next.js Middleware | 300ms+ | Serverless Cold Starts |
| UrlEdge | 25ms | Global Edge Network |
Configuration
With UrlEdge, you can import your CSV map or define regex rules directly.
{
"rules": [
{
"source": "^/products/(.*)",
"destination": "/shop/$1",
"type": 301
},
{
"source": "^/pages/contact-us",
"destination": "/contact",
"type": 301
}
]
}Step 4: Verification
Before flipping the DNS switch, you must verify your rules.
- Staging Environment: Point a staging domain to UrlEdge and test key URLs.
- Curl Test:
curl -I https://staging.store.com/products/old-product
# Expected Output:
# HTTP/2 301
# location: /shop/old-product
# x-urledge-rule: regex-product-match- Crawl Test: Use Screaming Frog or similar tools to crawl the old URL list against the new environment.
Conclusion
Migrating to headless is a major upgrade for your brand, but it requires surgical precision with URL routing.
By moving your redirect logic to the Edge, you decouple your routing from your frontend code, ensuring:
- Faster redirects for users.
- Cleaner codebases (no 5,000 line
redirects.jsfile). - Marketing agility (change rules without deploying code).
Ready to migrate? Start your free UrlEdge trial today.
Ready to optimize your redirects?
Start using UrlEdge today to manage your traffic at the edge.
Get StartedRelated Articles
View all
Firebase Dynamic Links Alternative: How to Replace It After the Shutdown
Firebase says Dynamic Links shut down on August 25, 2025. Learn how to replace them with branded smart links, app links, and safer fallback routing.

301 vs 302 vs 307 vs 308 Redirects: Which One Should You Use?
Use 301 or 308 for permanent moves, and 302 or 307 for temporary ones. The key question is whether the HTTP method must stay unchanged.