I took backup of AWS EC2 instance(magento2 is hosted on it i.e. HTTP://abc/magento2) by creating Image of it. Everything is backed up perfectly in backedup AMI(Amazon machine image).
Backed up AMI IP is now <HTTP://xyz/magento2>
When I run the above IP magento2 webpage is not loading instead its routing to <HTTP:/abc/magento2> .. its not routing to this IP <HTTP://xyz/magento2>
Can anyone please help me on this?
Solved! Go to Solution.
This is due to env.php file and core_config_data table.
In <HTTP://xyz/magento2>, you are using same env.php as HTTP://abc/magento2 which having same Database. in that database you can find core_config_data table where base url is defined for HTTP://abc/magento2 so it will redirect to on this only. once you will modify it and clear cache it will redirect to that.
This is due to env.php file and core_config_data table.
In <HTTP://xyz/magento2>, you are using same env.php as HTTP://abc/magento2 which having same Database. in that database you can find core_config_data table where base url is defined for HTTP://abc/magento2 so it will redirect to on this only. once you will modify it and clear cache it will redirect to that.
After modifying env.php and core_config_data it I ran these below commands:-
chmod -R 0777 var/ pub/ generated/
rm -rf var/cache/* pub/static/* generated/*
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
php bin/magento indexer:reindex
php bin/magento cache:flush
chmod -R 0777 var/ pub/ generated/
It worked