Sometimes we may not notice the URL of each website, however, this element plays a significant role in SEO. That’s why many marketers or merchants have to change the base URL overtime for the purpose of SEO best practices.
EXPLORE Magento 2 SEO guide for the complete settings to optimize your SEO!
Just like any website, each Magento website is assigned a base URL that is used for the frontend and Admin. If you have a security certificate for your domain, you can configure each or both base URLs to operate over a securely encrypted SSL channel.
For more details, unsecure base URLs begin with “http,” while secure base URLs begin with “https.”In this article, we will give you two methods to change the Magento 2 base URL. Enjoy the quick tutorial with a few clicks!
Change the Magento 2 base URL from the backend
Configure the unsecure base URL
In your Magento 2 admin panel, access Stores > Settings > Configuration.
- On the left menu, under General section, click on Web
- Expand Magento 2 Base URLs section. Enter the unsecure (http) Base URL for your store. Make sure to end the URL with a forward slash (“/”)
- (optional) If you don’t need a secure base URL for the backend, follow these steps:
- Expand Magento 2 Base URLs (Secure) section
- Enter your unsecured (http) base URL into the Secure Base URL field. The URL should be the same in both the Base URLs and Base URLs (Secure) sections
4. Click the Save Config button
Notes:
- To indicate a substitute location for the Magento Base URL for Static View Files, enter the path starting with the following placeholder: {{unsecure_base_url}}
- To specify a substitute location for the Magento Base URL for User Media Files, enter the path starting with the following placeholder: {{unsecure_base_url}}
- In case of a typical installation, you will not have to update the paths for the static view files or media files because they already take over the Magento base URL
Configure the secure base URL
- If your domain has been assigned a valid security certificate, you can configure the Magento URLs for both or either the storefront and Admin to run a secure (https) channel.In your Magento 2 backend, go to Stores > Settings > Configuration.
- On the left menu, under General section, click Web.
- Expand Base URLs (Secure) section. Then, do the following steps:
- To use a secure (https) for the storefront, enter the Secure Base URL, followed by a forward slash (“/”).
- If there is a need to run the entire storefront with a secure (https) channel, set Use Secure URLs on Storefront to Yes.
- If there is a need to run the entire Admin with a secure (https) channel, set Use Secure URLs in Admin to Yes.
- Click the Save Config button
Change the Magento 2 base URL by the command line
The following Magento 2’s CLI command will update the Magento base URL and the base-url-secure values.
1. Log in your Magento hosting server via SSH
2. Write in the following command
mysql -u $database_user -p $database_name
3. Enter the password when prompted
4. Use the following command to access the database, where the database is the name of the database
use database
5. Run the following command. The current base_urls set in Magento will be displayed in here
select * from core_config_data where path like '%base%url%';
6. To modify the Magento base URLs, enter the following commands
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';
That’s all!
We hope that this tutorial fits you well! Also, if you have any questions or sharing, don’t hesitate to write to us in the comments below!
BSS Commerce is one of the leading Magento extension providers and web development services in the world. With experienced and certified Magento developers, we commit to bring high-quality products and services to optimize our business effectively.
CONTACT NOW to let us know your problems. We are willing to support you every time.