We come across this from time to time and it’s a common issue when a client changes their domain name due to a rebrand or upgrade from .co.uk to .com
When we changed a Base Url Change Magento 2 there are several sets to take but as always please take this as a guide and backup, backup and backup before modifying your Database.
So, let’s dive straight and take an example that our client is changing from a .co.uk to a .com. example www.domain.co.uk to www.domain.com
Lets Go.
Log in to your server via SSH (we are using a terminal on a mac)
Connect to your Database – this can be controlled like this:
mysql -u root -p
Enter password when asked.
Then we need to update baseurl in core_config_data:
UPDATE core_config_data
> SET value = 'http://www.yourdomain2.com/'
> WHERE path IN ('web/secure/base_url', 'web/unsecure/base_url')
Next Step
UPDATE core_config_data
> SET value = REPLACE(value, 'http://www.domain.co.uk/', 'http://www.domain.com/')
>WHERE path = 'design/head/includes';
If this throws up an error use following: This happened to us on the MariaDB cloud server
Change the web/unsecure/base_link_url also:
UPDATE core_config_data
> SET value = 'http://www.yourdomain2.com/'
> WHERE path IN ('web/unsecure/base_link_url');
Then changed Store Url
php bin/magento setup:store-config:set --base-url="http://www.domain.com/"
php bin/magento setup:store-config:set --base-url-secure="https://www.domain.com/"
Finally to finish clearthe cache:
php bin/magento cache:flush