How to Change Magento 2 Base URL
Magento 2 store URL may not be paid much attention but it plays an important role in Magento SEO.
Every Magento 2 store has a base URL. In this post, I’ll show the methods to change Magento 2 base URL
You can use this method when you want to change the domain URL. With the below method, the base URL can be changed easily and all the sub-URLs will be redirected with the new base URL.
You can use this method when:
- You want to develop a staging site
- You want to change the server setup
- You want a development site
- You want to have a subdomain site
- Simply want to change the domain
In all these cases, follow the below method to change the base URL in Magento 2.
Methods to change Magento 2 Base URL:
Change domain helloworld.com to helloworld.in using any of the below methods:
-
Using CLI command:
12bin/magento setup:store-config:set --base-url="http://helloworld.in/"bin/magento setup:store-config:set --base-url-secure="https://helloworld.in/" -
Using Table:
1234567UPDATE core_config_dataSET value = 'http://helloworld.in/'WHERE path IN ('web/secure/base_url', 'web/unsecure/base_url');UPDATE core_config_dataSET value = REPLACE(value, 'http://helloworld.com/', 'http://helloworld.in/')WHERE path = 'design/head/includes';
That’s it.
Any doubts in the above method can be mentioned in the Comments section below. I’d be happy to help you out.
Also, do not forget to share the post with the Magento community via social media.
Thank you.
Also Read:
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
6 Comments
What is the use of 2nd row in core_config_data, where path=’design/head/includes’;
Hey,
Try
design/head/includes specify the value mentioned in Design->Configuration->Edit Theme at Head section.
Hi, So i updated directly in the database but when I load on FE it still redirects to old link. Is there more commands i should run after updating the secure & unsecure urls?
Hello Karen,
Please check after clearing or caching the flush.
Thank You
In the last couple of days, I find some solutions but not get yet. my problem is without an SSL certificate change URL in Magento.
Hello Nayan,
You can change secure and unsecure both URL using the above solution.
Thank You