将WordPress站点的WooCommerce迁移至子域名求助
Hey there! Moving your WooCommerce store (including shop, cart, account pages, etc.) to a subdomain is totally achievable— I’ve walked through this process with several users before, so let’s break down the key steps and critical things to keep in mind:
1. Pre-Migration Prep (Don’t Skip This!)
- First off, back up your entire main site— database, core files, themes, plugins, and all WooCommerce data. Use a backup plugin or your host’s backup tool; you’ll want a safety net if anything goes sideways.
- Confirm your hosting provider supports subdomains (most do). Head to your host’s control panel to create the subdomain (e.g.,
shop.yourdomain.com) and assign it to a dedicated directory on your server.
2. Set Up the Subdomain WordPress Installation
- Install a fresh WordPress instance on your new subdomain. You can use your host’s one-click installer or manually upload the WP core files.
- Activate the WooCommerce plugin on the subdomain site, but hold off on configuring settings (like payment gateways or shipping) until after data migration.
3. Migrate WooCommerce Data
- Export from your main site: Go to
WooCommerce > Tools > Exportin your main WordPress dashboard. Select all the data types you need (products, orders, customers, coupons, etc.) and download the CSV files. - Import to the subdomain: On the subdomain’s WooCommerce dashboard, go to
WooCommerce > Tools > Import. Upload the CSV files you exported, double-check that fields match correctly, and run the import. Afterward, verify that all data transferred properly (product images, inventory levels, order statuses, etc.). - For more precise control (if you’re comfortable with databases): Use phpMyAdmin to export tables related to WooCommerce from your main site’s database (e.g.,
wp_posts,wp_postmeta,wp_woocommerce_products,wp_woocommerce_orders). Import these tables into the subdomain’s database, then update thesiteurlandhomevalues in thewp_optionstable to your subdomain’s URL.
4. Update URLs & Fix Broken Links
- Bulk replace old URLs: Use a search-replace tool to update all internal links from your main domain to the subdomain. If you use WP CLI, run this command (replace the domain examples with yours):
Alternatively, use a reputable WordPress plugin designed for search-replace.wp search-replace 'https://yourdomain.com' 'https://shop.yourdomain.com' --skip-columns=guid - Configure WooCommerce settings: On the subdomain site, go to
WooCommerce > Settingsand update all URL-related fields (shop base address, cart page, account page, checkout page) to point to the subdomain. - Set up 301 redirects: Add rules to your main site’s
.htaccessfile to redirect old WooCommerce pages to the subdomain. This preserves SEO and user experience. Example rules:RedirectMatch 301 ^/product/(.*)$ https://shop.yourdomain.com/product/$1 RedirectMatch 301 ^/cart/$ https://shop.yourdomain.com/cart/ RedirectMatch 301 ^/my-account/(.*)$ https://shop.yourdomain.com/my-account/$1 RedirectMatch 301 ^/checkout/(.*)$ https://shop.yourdomain.com/checkout/$1
5. Test Every Critical Function
- Walk through the full customer journey: Browse products, add items to cart, proceed to checkout, test payment gateways (use sandbox mode!), log into customer accounts, and view order history.
- Check for broken images, dead links, or styling issues— especially if you’re using a custom theme. Make sure your theme and WooCommerce-compatible plugins work seamlessly on the subdomain.
- Test on mobile devices to ensure responsive design holds up, and clear all cache (on both main site and subdomain) to avoid serving outdated content.
6. Post-Migration Maintenance
- Set up regular backups for the subdomain site separately from your main site.
- Keep WordPress, WooCommerce, plugins, and themes on the subdomain updated to the latest versions (same as your main site, if applicable).
- Submit the subdomain’s sitemap to Google Search Console and monitor traffic/metrics to ensure no significant drops in visibility or conversions.
A few extra tips:
- If your main site and subdomain are on the same server, double-check file permissions to avoid access errors.
- If you use a CDN, update its settings to include the subdomain and purge cached content after migration.
内容的提问来源于stack exchange,提问作者brad walls
相关产品推荐
相关产品推荐

