Magento Multistore Redirect Issue After Migration
Introduction
If you’ve recently migrated a Magento multistore installation to a new server but are still experiencing redirects to the old domain, you’re not alone. This common issue can be quite frustrating, especially when all other migration steps seem to have been executed correctly.
In this post, we’ll delve into the root causes of multistore redirection problems after migration and provide step-by-step solutions to resolve them effectively.
Understanding the Redirect Issue
When migrating a Magento multi-store setup, it’s crucial that both the domain and base URL settings are updated accurately. The issue often arises due to lingering references to the old domain in various system tables, configuration files, or even hardcoded URLs within templates.
The specific symptoms you’ve describedâ redirects to the old domain despite changing base_url values and clearing cache/session dataâindicate that there may be residual configurations pointing back to the old setup.
Comprehensive Troubleshooting Steps
Step 1: Verify Base URL Configurations
Ensure that both the web/unsecure/base_url and web/secure/base_url configuration settings are updated in the core_config_data table for each site.
UPDATE core_config_data
SET value = 'https://mynewstore.com'
WHERE path LIKE '%base_url%';
Step 2: Clear Cache, Session, and Log Files
Remove all cached data, temporary files, and session data associated with the Magento installation. This includes clearing the var/cache, var/session folders and the database core_session table.
rm -rf var/cache/*
rm -rf var/session/*
Step 3: Reindex Database
Re-index all enabled indexes to ensure that updated data is reflected in the catalog-related tables. You can do this using the following command:
php bin/magento indexer:reindex
Step 4: Examine Index.php Configuration
The index.php file serves as a critical entry point for Magento requests, and any misconfigurations here can lead to redirects.
# Check if $mageRunCode and $mageRunType are correctly set
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Ensure that these variables are properly populated based on the new store setup. If you’re using symlinks for your subdomains, you may need to adjust these values accordingly.
Step 5: Inspect .htaccess and Template Files
Double-check the .htaccess file for any remnant redirect rules pointing back to the old domain. Similarly, review all template files across different stores for hardcoded URLs or incorrect base URL references.
Advanced Debugging Techniques
If the basic steps fail to resolve the issue, you might need to enable Magento’s debug mode and log system settings to pinpoint the exact cause of the redirection problem.
Enabling Debug Mode
Add MAGE_LOG=0 in your .htaccess file or modify the app/bootstrap.php file:
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
Mage::setIsDeveloperMode(true);
}
This setting will help you identify any misconfigured URLs or system errors that could be causing the redirects.
Conclusion
Resolving multistore redirection issues after a Magento migration requires a systematic approach, combining database updates, file inspections, and advanced debugging techniques. By following the steps outlined above, you should be able to successfully point your new installation to the correct domain without any further redirects.
Remember that accurate configuration is key in maintaining the integrity of your multi-store setup. If you continue to encounter difficulties, consult the official Magento documentation or seek professional assistance from experienced Magento developers at Laravel Company.
Happy troubleshooting!