How to Change Magento 2 Base URL?

Change Magento 2 Base URL

Do you want to change Magento 2 Base URL?

The URL of the eCommerce store plays an important role in SEO. You must keep the base URL as clean as possible to follow the best Magento SEO practices.

All the websites have two types of base URL. One for the admin dashboard, and another for the frontend.

You can either keep these URLs secure or unsecure.

Secure means the page loads on the HTTPS, keeping the data safe. While HTTP is unsecure and without the SSL certificate.

Read more about the HTTP and HTTPS.

Google favours the secured sites while ranking in SERP.

#1 Change Magento 2 Base URL From The Backend

Go to your Magento 2 admin panel. 

Navigate to the Stores > Settings > Configuration

Step 1: Look at the left Menu, see the General section and Click on the Web.

Left Menu > General Section > Web

Step 2: Click on the Magento 2 Base URL section to expand it. 

Enter the Base URL of the store.

Note: Make sure that the URL ends with a forward slash.

Change Magento 2 Base URL

Step 3: Save the Configuration.

If you want to make the Magento 2 Base URL secure, then you can follow these steps.

To configure the secure HTTPS for the storefront, add the secure base URL . (https instead of http)

  • Enable the Storefront to Yes: The entire storefront will run on the secure https.
  • Enable the Admin to Yes: The entine admin dashboard will run on https.

Save the configuration.

#2 Change Magento 2 Base URL By The Command Line

You can change the Magento 2 Base Url from the command line.

Follow these steps:

Step 1: Log in to your server via SSH

Step 2: Type the following command:

mysql -u $database_user -p $database_name

Enter the password.

Step 3: Write the following command. It will give you access to the database.

Put the name of the database at the place of the “database”.

use database  

Step 4: Use the following command to display the current base_urls.

select * from core_config_data where path like '%base%url%';

Step 5: Run the following command to change the Magento 2 Base URL.

update core_config_data set value = 'http://example.com/' where path = 'web/unsecure/base_url';
update core_config_data set value = 'https://example.com/' where path = 'web/secure/base_url';

Also Read

Final Words

I hope this tutorial helped you in changing the Magento 2 Base URL. 

If there are any questions or any issues, then leave them in the comments.

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new modules, and more. 100% Magento Goodness, a promise!

Leave a Comment

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.

Scroll to Top

We can help you. Right now.

Fast growing merchants depend ServerGuy for high-performance hosting. Experience counts. Let's get started.

Talk to a sales representative

USA / Worldwide

+1.714.2425683

India

+91.9852704704

Core Web Vitals Book COver

Is your website ready for Core Web Vitals?

Take this FREE book with you and optimize your store for speed.

Learn all about new Google new ranking factors and get that top ranking.