HostOnNet Blog

Change Magento 2 URL

Looking for Linux Server Admin or WordPress Expert? We can help.

To change Magento 2 web site URL/domain name, run following SQL commands

UPDATE core_config_data SET value = 'http://m2.hostonnet.com/'  WHERE path='web/unsecure/base_url';
UPDATE core_config_data SET value = 'http://m2.hostonnet.com/'  WHERE path='web/unsecure/base_link_url';
UPDATE core_config_data SET value = 'https://m2.hostonnet.com/'  WHERE path='web/secure/base_url';
UPDATE core_config_data SET value = 'https://m2.hostonnet.com/'  WHERE path='web/secure/base_link_url';

You need to flush cache with CLI

php bin/magento cache:flush

You can verify the URLs are set properly in DB with

MariaDB [hon_mage2]> select * from core_config_data where value like "http%";
+-----------+---------+----------+----------------------------+--------------------------+
| config_id | scope   | scope_id | path                       | value                    |
+-----------+---------+----------+----------------------------+--------------------------+
|         2 | default |        0 | web/unsecure/base_url      | http://m2.hostonnet.com/ |
|         3 | default |        0 | web/secure/base_url        | http://m2.hostonnet.com/ |
|        70 | default |        0 | web/unsecure/base_link_url | http://m2.hostonnet.com/ |
|        73 | default |        0 | web/secure/base_link_url   | http://m2.hostonnet.com/ |
+-----------+---------+----------+----------------------------+--------------------------+
4 rows in set (0.00 sec)

MariaDB [hon_mage2]> 

You can also use CLI like

php bin/magento setup:store-config:set --base-url="http://m2.hostonnet.com/"
php bin/magento setup:store-config:set --base-url-secure="https://m2.hostonnet.com/"
php bin/magento setup:store-config:set --base_link_url="http://m2.hostonnet.com/"
php bin/magento setup:store-config:set --base_link_url-secure="https://m2.hostonnet.com/"
php bin/magento cache:flush

See Magento 2

Posted in Web

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.