Magento

How to change base URLs in Magento 2.3 and 2.4

Pinterest LinkedIn Tumblr

Changing from the database is the best way to update the database even if you using multiple stores also. you can change the base URL just by using 2 commands.

Step 1: Open your Phpmyadmin and login to using database user name and password. and if you forget what is your credentials you can check from .env file which is located in your folder app/etc/env.php file.

For example:

'dbname' => 'magento',
'username' => 'root',
'password' => 'root',

Step 2: Select the database associate with your Magento 2 website and search for table core_config_data, find the following lines:

web/unsecure/base_url
web/secure/base_url

Click edit and change value to your new base URL (remember to put slash at the end of every URL and put https in web/secure/base_url).

update core_config_data set value = 'http://url.local/' where path = 'web/unsecure/base_url';

update core_config_data set value = 'http://url.local/' where path = 'web/secure/base_url';

Start by removing all https from your config

UPDATE core_config_data
SET value=REPLACE(value, 'https', 'http') 
WHERE value LIKE 'https%';

Then remove the secure redirection

UPDATE core_config_data
SET value=0
WHERE path='web/secure/use_in_frontend' OR path='web/secure/use_in_adminhtml' OR path='web/url/redirect_to_base';

And the most important after this: delete content of

var/cache
var/full_page_cache
var/session