How to Configure Store URLs in Magento 2?

Configuration of the store URLs in Magento 2 is one of the first steps you'll take while setting up eCommerce store with Magento. Once you configure base and admin URLs, it will be easier to move an entire store from one location to the other without having to update the URLs.

Besides, understanding the Magento URL structure is an advantage while developing a store. In this article, you'll find the steps on how to configure Magento store URLs, as well as some other recommendations. 

Ready? Let's begin! 

Types of URLs in Magento 2

After you install Magento, you'll get a storefront base URL and admin URL. All the internal links are then defined with the help of the variables added to the base URL. This pattern is rather convenient since it enables you to move your store to a different location without changing all the links.

In general, there are 3 types of URLs in Magento. 

URL type


Base URL

Secure Base URL

URL with IP address



Note: if you manage multilanguage Magento, you also need to add the store code directly to the URLs

To configure store URLs in Magento 2, go to Stores > Settings > Configuration > General > Web and follow the steps below. 

Base URLs Configuration

1. Find the Base URLs section.

2. Enter the Base URL of your store. Don't forget to place a slash "/" at the end so that the corresponding URL keys could be added later on.  

3. Don't edit the content of the Base Link URL field, since the preset placeholder is used to create relative base URL links. 

 Base URL configuration

4. Two remaining fields — Base URL for Static View Files and Base URL for User Media Files — are optional. Still, if you want to create paths for the static view or user media files, add the corresponding links starting with the following placeholder: {|{unsecure_base_url}}.

Base URLs in Magento 2

Secure Base URLs Configuration 

1. Unfold the Base URLs (Secure) section. 

2. Add the Secure Base URL of your store, closing it with a slash "/".

3. You shouldn't change the content of the Secure Base Link URL, as the placeholder written there is used to create relative secure base URLs. 

4. Just like in the previous section, the Secure Base URL for Static View Files and Secure Base URL for User Media Files fields are optional. However, if you need, you can add corresponding links here using one of the following placeholders: {|{secure_base_url}} or {|{unsecure_base_url}}.

Configuration of the secure base URLs

5. For the Use Secure URLs on Storefront and Use Secure URLs in Admin options choose Yes to improve Magento security.

6. Select either Yes or No in the Enable HTTP Strict Transport Security (HSTS) field. This option defines whether only secure https requests will be displayed in your store. 

7. In the Upgrade Insecure Requests field choose Yes, if you want to convert all the insecure http pages into secure https ones.

8. Specify the Offloader header depending on your server configuration. 

Secure base URLs in Magento 2

URL Options Configuration

1. Move to the Url Options section.

2. In the Add Store Code to Urls field choose either Yes or No, depending on whether you operate multiple stores and want to add their identifiers to the URL. 

3. Set the Auto-redirect to Base URL option.

4. Select one of the available options for the Catalog media URL format

Add store code to the URL in Magento 2

Don't forget to Save the settings button once you finish. 

This configuration will help you to organize the URL structure of your store better and optimize various navigation processes. However, once you configure store URLs in Magento, you also need to check how to set up default pages.