How to Move Magento to a New Domain
Changing the domain of a Magento store requires more than pointing a new domain to the existing server. Magento stores the website URL in its configuration, and references to the old domain may also exist in the database, cached data, media, emails, redirects, and third-party integrations.
A poorly planned domain migration can result in broken links, redirect loops, missing images, checkout problems, SSL errors, or lost search-engine rankings.
The safest approach is to prepare the new domain, back up the store, update Magento’s base URLs, carefully replace old domain references where necessary, configure redirects, install SSL, test the entire store, and monitor the migration after launch.
This guide explains how to move a Magento store from an old domain to a new domain while minimizing downtime and SEO problems.
Example Domain Migration
Suppose your current Magento store is:
https://oldstore.com
and you want to move it to:
https://newstore.com
The migration will look like this:
Old Domain
oldstore.com
|
| Magento Store
↓
Update Configuration
|
↓
New Domain
newstore.com
|
↓
301 Redirects
|
↓
Search Engines / Visitors
The old domain should generally remain available so that visitors and search engines can be redirected to the corresponding pages on the new domain.
Why Move a Magento Store to a New Domain?
There are several reasons a business might change its domain:
- Rebranding
- Company name change
- Better domain name
- International expansion
- Merging websites
- Marketing strategy
- Moving to a new brand
- Changing from a temporary domain to a permanent domain
Whatever the reason, the migration should be planned as a website move rather than simply changing DNS.
What You Need Before Starting
Before changing the Magento domain, make sure you have access to:
- Magento Admin Panel
- Magento server
- SSH
- Database
- DNS management
- SSL certificate management
- Web server configuration
- Search Console accounts
- Analytics platform
- CDN or WAF configuration
- Email configuration
Also create a complete backup before making changes.
Step 1: Create a Complete Magento Backup
Before modifying the domain configuration, back up the store.
Your backup should include:
- Magento database
- Magento files
- Product images
- Media
- Custom modules
- Custom themes
- Configuration
- Composer files
A database backup can be created using:
mysqldump -u DB_USER -p DATABASE_NAME > magento-backup.sql
For a compressed backup:
mysqldump -u DB_USER -p DATABASE_NAME | gzip > magento-backup.sql.gz
Keep the backup separate from the production website.
Do not begin the domain migration until you have a verified recovery point.
Step 2: Prepare the New Domain
Register or configure the new domain before changing Magento.
For example:
newstore.com
Configure DNS records to point to the Magento server.
Depending on your setup, you may need records such as:
newstore.com → Server IP
www.newstore.com → Server IP
If you use a CDN or reverse proxy, configure the new domain there as well.
Step 3: Install SSL for the New Domain
The new domain should use HTTPS.
Configure an SSL certificate for:
https://newstore.com
and, if required:
https://www.newstore.com
Test the certificate before changing Magento’s URLs.
Make sure:
- The certificate is valid
- The certificate chain is complete
- HTTPS works
- HTTP can redirect to HTTPS
- The CDN/proxy SSL configuration is correct
Step 4: Add the New Domain to the Web Server
Configure your Apache or Nginx server to recognize the new domain.
The web server should point the new domain to Magento’s pub directory.
For example:
/var/www/magento/pub
Do not point the public website directly at the entire Magento project root.
After configuring the new virtual host/server block, reload the web server.
For example, depending on your system:
systemctl reload nginx
or:
systemctl reload apache2
Step 5: Check Your Current Magento URLs
Before making changes, check the current Magento Base URLs.
Run:
php bin/magento config:show web/unsecure/base_url
and:
php bin/magento config:show web/secure/base_url
You may see:
https://oldstore.com/
These values need to be changed to the new domain.
Step 6: Update Magento Base URLs
From the Magento root directory, update the base URL:
php bin/magento setup:store-config:set --base-url="https://newstore.com/"
Then configure the secure URL:
php bin/magento setup:store-config:set --base-url-secure="https://newstore.com/"
If your installation uses a separate www version, use the URL you intend to make canonical.
For example:
https://newstore.com/
rather than inconsistently mixing:
https://newstore.com/
https://www.newstore.com/
Choose one canonical version and use redirects for the other.
Step 7: Make Sure HTTPS Is Enabled
Magento should use HTTPS for both the storefront and Admin Panel.
You can configure secure frontend access with:
php bin/magento config:set web/secure/use_in_frontend 1
For the Admin Panel:
php bin/magento config:set web/secure/use_in_adminhtml 1
Then flush the cache:
php bin/magento cache:flush
Step 8: Check for the Old Domain in the Database
Changing the Base URL does not necessarily replace every occurrence of the old domain.
The old domain may appear in:
- CMS pages
- CMS blocks
- Product descriptions
- Category descriptions
- Custom HTML
- Configuration
- Third-party extension settings
- Email templates
- Custom code
Before performing a global replacement, create another database backup.
Do not blindly replace every occurrence of the old domain because some values may need to remain unchanged for redirects, historical records, integrations, or other purposes.
For controlled replacements, identify the specific tables and fields that contain the old domain and update only the appropriate values.
Step 9: Search the Magento Files for the Old Domain
Custom code may contain the old domain.
From the Magento directory, you can search for references with:
grep -R "oldstore.com" app/ --exclude-dir=cache
You can also search custom modules:
grep -R "oldstore.com" app/code/
And custom themes:
grep -R "oldstore.com" app/design/
Review every result before changing it.
Do not automatically replace domain names inside third-party libraries or generated files.
Step 10: Clear Magento Cache
After changing the Base URLs, clear the Magento cache:
php bin/magento cache:flush
Check cache status:
php bin/magento cache:status
If your environment uses additional caching systems such as Redis or Varnish, clear or purge those caches according to your deployment configuration.
Step 11: Clear Generated Data When Necessary
If your Magento deployment requires regenerated static assets, run:
php bin/magento setup:static-content:deploy -f
You may also need:
php bin/magento setup:di:compile
The exact deployment process depends on your Magento version and production workflow.
Do not unnecessarily delete production files without understanding what your deployment process requires.
Step 12: Reindex Magento
Check indexer status:
php bin/magento indexer:status
If necessary, rebuild indexes:
php bin/magento indexer:reindex
Then check again:
php bin/magento indexer:status
Test product search, categories, layered navigation, and other catalog functionality after reindexing.
Step 13: Configure 301 Redirects From the Old Domain
One of the most important parts of a domain migration is redirecting the old domain to the new domain.
For example:
https://oldstore.com/product/example
should redirect to:
https://newstore.com/product/example
Use 301 permanent redirects for permanent domain changes.
Avoid redirecting every old URL to the new homepage when an equivalent page exists.
The ideal structure is:
Old product URL
↓
301 Redirect
↓
New product URL
This provides a better experience for users and helps search engines understand the migration.
Step 14: Configure Apache Redirects
If the old domain and new domain are handled by Apache, a redirect can be configured in the old domain’s virtual host or appropriate configuration.
A basic example is:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^oldstore\.com$ [NC]
RewriteRule ^(.*)$ https://newstore.com/$1 [R=301,L]
If you also use the www version, include the appropriate hostname rules.
Test redirects carefully to avoid redirect loops.
Step 15: Configure Nginx Redirects
With Nginx, you can create a dedicated server block for the old domain.
A simplified example:
server {
listen 80;
server_name oldstore.com www.oldstore.com;
return 301 https://newstore.com$request_uri;
}
This preserves the requested path.
For example:
oldstore.com/category/shoes
can redirect to:
newstore.com/category/shoes
The exact configuration should match your existing HTTPS and server architecture.
Step 16: Do Not Redirect the New Domain Back to the Old Domain
After changing Magento’s Base URLs, verify that the new domain does not redirect back to the old one.
For example, this is incorrect:
newstore.com
↓
oldstore.com
↓
newstore.com
This creates a redirect loop.
Test both domains independently.
Step 17: Check Canonical URLs
Magento and your SEO configuration should use the new domain as the canonical domain.
Check product pages, category pages, CMS pages, and other important URLs.
For example:
<link rel="canonical" href="https://newstore.com/product/example">
The canonical URL should not continue pointing to the old domain after the migration.
Step 18: Update XML Sitemap
After changing the domain, regenerate or update the Magento XML sitemap so that URLs use the new domain.
Your sitemap should contain URLs such as:
https://newstore.com/
https://newstore.com/category/example
https://newstore.com/product/example
It should not continue listing the old domain.
Submit the new sitemap to your search-engine tools after the migration.
Step 19: Update Robots.txt
Check your robots.txt file.
Make sure it does not contain references to the old domain that should now point to the new one.
If you have a sitemap declaration, update it.
For example:
Sitemap: https://newstore.com/sitemap.xml
Be careful not to accidentally block the new site during migration.
Step 20: Update Google Search Console
If you use Google Search Console, add and verify the new domain.
Submit the new sitemap.
For a domain migration, use the appropriate site-move functionality where available and follow Google’s current migration guidance.
Also monitor:
- Indexing
- Coverage
- Redirects
- Crawl errors
- Search traffic
- Sitemap processing
Expect search visibility to fluctuate temporarily while search engines process the domain change.
Step 21: Update Analytics
Update your analytics configuration to recognize the new domain.
Depending on your analytics setup, check:
- Measurement configuration
- Referral exclusions
- Cross-domain settings
- Conversion tracking
- Ecommerce tracking
- Payment gateway referral handling
Test an actual purchase or test transaction where appropriate.
Step 22: Update Third-Party Services
Your Magento store may use services that are tied to the old domain.
Review:
- Payment gateways
- Shipping APIs
- Tax services
- Email platforms
- SMTP services
- CDN
- WAF
- CAPTCHA
- Fraud detection
- Marketing platforms
- Webhooks
- OAuth applications
- Social login
- Product feeds
Update the callback URLs, webhook URLs, API settings, or allowed domains where necessary.
Step 23: Update Email Configuration
If your business email is changing along with the domain, configure the new email addresses separately.
For example:
[email protected]
[email protected]
Update Magento’s transactional email configuration and verify:
- Sender addresses
- SMTP settings
- SPF
- DKIM
- DMARC
Send test emails for:
- New account
- Order confirmation
- Shipment
- Password reset
- Contact form
Step 24: Test Customer Accounts
Customer accounts should continue working after the domain migration.
Test:
- Customer login
- Registration
- Password reset
- Account dashboard
- Order history
- Saved addresses
- Wishlist
- Stored preferences
Pay particular attention to login cookies and HTTPS configuration.
Step 25: Test Checkout and Payments
Checkout is one of the most important parts of a Magento domain migration.
Perform a complete test order.
Check:
- Cart
- Customer information
- Billing address
- Shipping address
- Shipping method
- Tax
- Coupon
- Payment method
- Order placement
- Confirmation page
- Confirmation email
- Payment gateway callback
A store should not be considered successfully migrated until checkout has been tested.
Step 26: Check Product Images
Open several product pages and verify that images load correctly.
Also inspect:
pub/media/
If images reference the old domain, identify whether those references are generated by Magento, stored in content, or created by custom code.
Do not blindly modify image URLs without understanding how your Magento media system generates them.
Step 27: Check Internal Links
Search your site for links that still point to the old domain.
Check:
- Navigation
- Product descriptions
- Category descriptions
- CMS pages
- CMS blocks
- Footer links
- Blog content
- Custom landing pages
Internal links should generally point directly to the new domain rather than relying on unnecessary redirects.
Step 28: Test the Magento Admin Panel
Access the Admin Panel using the new domain.
For example:
https://newstore.com/your-admin-path/
Verify:
- Login
- Dashboard
- Products
- Categories
- Orders
- Customers
- Configuration
- Extensions
- Reports
If you previously customized the Magento Admin URL, preserve that configuration during the domain migration.
Step 29: Test the Site Before Going Live
Before announcing the new domain, perform a complete test.
Frontend
- Homepage
- Categories
- Products
- Search
- Images
- CMS pages
- Customer registration
- Customer login
- Cart
- Checkout
Backend
- Admin login
- Product management
- Order management
- Customer management
- Configuration
- Extensions
Technical
- HTTPS
- DNS
- Redirects
- Canonical URLs
- Sitemap
- Robots.txt
- Cron
- Cache
- Indexers
- Payment gateway
Step 30: Monitor the Old Domain
Do not immediately remove the old domain.
Keep it active and redirect it to the new domain.
Monitor:
- Redirect traffic
- 404 errors
- Search-engine crawling
- Referral traffic
- Analytics
- Server logs
This allows visitors and search engines to discover the new domain.
Common Magento Domain Migration Problems
Redirect Loop
If the new domain keeps redirecting between HTTP and HTTPS or between the old and new domains, check:
- Magento Base URLs
- SSL configuration
- CDN settings
- Web-server redirects
- Proxy headers
Make sure only one canonical URL is being enforced.
Images Still Use the Old Domain
Check:
- Magento Base URLs
- CMS content
- Product descriptions
- Theme files
- Custom modules
- CDN configuration
Avoid performing uncontrolled database replacements.
Admin Panel Redirects to the Old Domain
Check Magento’s secure Base URL and any custom Admin configuration.
Clear Magento cache afterward:
php bin/magento cache:flush
Checkout Does Not Work
Check:
- HTTPS
- Payment gateway configuration
- JavaScript errors
- Cookie configuration
- Third-party callbacks
- Base URLs
- CDN/WAF rules
Test the payment gateway separately if required.
Customers Cannot Log In
Check:
- HTTPS
- Cookies
- Session configuration
- Redis
- Base URLs
- CDN caching
- Browser cache
Clear application caches and test in a private browser window.
Search Rankings Drop
A temporary fluctuation can occur after a domain migration.
Reduce the risk by:
- Using permanent redirects
- Preserving URL paths where possible
- Updating canonical URLs
- Updating XML sitemaps
- Verifying the new domain
- Monitoring crawl errors
- Updating important external links
- Maintaining relevant content
Do not intentionally change the domain and URL structure at the same time unless there is a strong reason to do so.
Best Practices for Magento Domain Migration
Keep URL Paths the Same
If possible, preserve:
oldstore.com/product/example
as:
newstore.com/product/example
This makes the migration easier to manage and reduces unnecessary URL changes.
Use 301 Redirects
Permanent redirects should connect old URLs with their corresponding new URLs.
Keep the Old Domain Active
Do not immediately cancel the old domain.
Back Up Before Changes
Create and verify a complete backup before modifying Magento.
Test Before Launch
Use a controlled environment to test the new domain before making it public.
Update External Services
Payment gateways, APIs, email systems, CDNs, and other services may require domain changes.
Monitor After Launch
Continue monitoring errors, traffic, indexing, and checkout after the migration.
Magento New Domain Migration Checklist
Preparation
- Register/configure new domain
- Configure DNS
- Install SSL
- Configure web server
- Back up Magento
- Back up database
- Record current configuration
Magento Configuration
- Update Base URL
- Update Secure Base URL
- Enable HTTPS
- Flush cache
- Reindex
- Deploy static content if required
- Verify Admin URL
SEO
- Configure 301 redirects
- Update canonical URLs
- Update XML sitemap
- Check robots.txt
- Verify new domain in Search Console
- Submit new sitemap
- Monitor crawl errors
Integrations
- Update payment gateways
- Update shipping services
- Update tax services
- Update SMTP
- Update CDN/WAF
- Update webhooks
- Update API callbacks
- Update analytics
Testing
- Test homepage
- Test products
- Test categories
- Test search
- Test customer login
- Test password reset
- Test cart
- Test checkout
- Test payments
- Test emails
- Test Admin Panel
- Check redirects
- Check HTTPS
Final Thoughts
Moving Magento to a new domain requires careful coordination between Magento configuration, DNS, SSL, web-server settings, database content, redirects, SEO, and third-party integrations.
The safest approach is to back up the store first, prepare the new domain and server, update Magento’s Base URLs, preserve existing URL paths where possible, configure permanent redirects, update external services, thoroughly test the store, and monitor the old and new domains after launch.
Most importantly, avoid treating a domain change as a simple DNS update. Magento, search engines, customers, payment providers, and external services all need to recognize the new domain. A well-planned migration can make the transition smooth while minimizing downtime, broken links, and SEO disruption.