Magento Base URL Configuration: How to Change Magento Base URL
The Magento Base URL is one of the most important configuration settings in a Magento store. It tells Magento where your website is located and determines how Magento generates links to pages, products, categories, images, CSS files, JavaScript files, and other resources.
If you are moving a Magento store to a new domain, switching from HTTP to HTTPS, setting up Magento on localhost, or troubleshooting incorrect redirects and broken links, you may need to update the Magento Base URL.
In this guide, you will learn how to configure the Magento Base URL, change the secure and unsecure URLs, update the Base URL after a domain migration, and troubleshoot common Base URL problems.
What Is a Magento Base URL?
A Base URL is the main web address Magento uses to generate URLs throughout your online store. For example:
https://www.example.com/
Magento uses this URL as the foundation for links to your catalog, products, categories, CMS pages, media files, and other store resources.
Magento generally uses separate settings for Unsecure Base URL and Secure Base URL. These settings allow you to control how Magento handles normal HTTP requests and HTTPS requests.
Why Is the Magento Base URL Important?
Incorrect Base URL configuration can cause several problems, including:
- Broken links and incorrect redirects
- CSS and JavaScript files failing to load
- Images displaying incorrectly
- Magento redirecting to the wrong domain
- HTTP and HTTPS redirect loops
- Duplicate URL issues
- Problems after migrating Magento to a new domain
- Admin or storefront pages becoming inaccessible
For this reason, the Base URL should be configured correctly whenever you install Magento or move an existing Magento store.
How to Change Magento Base URL From the Admin Panel
If you can access the Magento Admin Panel, you can change the Base URL from the Web configuration settings.
Step 1: Log in to your Magento Admin Panel.
Step 2: Navigate to:
System >> Configuration >> Web >> Unsecure >> Base URL
Step 3: Update the Base URL with your website address.
For example:
https://www.example.com/
Step 4: Next, navigate to:
System >> Configuration >> Web >> Secure >> Base URL
Step 5: Enter the secure URL:
https://www.example.com/
Step 6: Save the configuration and clear the Magento cache.
It is important to include the trailing slash in the Base URL where required by your Magento configuration.
Secure vs. Unsecure Magento Base URL
Magento provides separate Base URL settings for secure and unsecure connections.
Unsecure Base URL
The Unsecure Base URL is traditionally used for HTTP requests. An example is:
http://www.example.com/
Secure Base URL
The Secure Base URL is used for HTTPS requests:
https://www.example.com/
For modern Magento stores, HTTPS should generally be used throughout the storefront. An SSL certificate helps protect data transferred between visitors and your website and is also important for security and user trust.
How to Change Magento Base URL When Moving to a New Domain
If you migrate your Magento store from one domain to another, updating the Base URL is an essential step.
For example, suppose your old store is:
https://old-domain.com/
and the new store is:
https://new-domain.com/
You should update the Magento Base URL settings to use the new domain.
After changing the URL, also check your Magento configuration, cache, redirects, canonical URLs, sitemap, robots.txt, and any third-party integrations that may contain the old domain.
How to Set the Magento Base URL on Localhost
Developers often install Magento locally for testing and development. In that case, the Base URL should point to the local Magento installation.
For example:
http://localhost/magento/
Depending on your local development environment, you may instead use a custom local domain such as:
http://magento.local/
Make sure the configured URL matches the actual virtual host, directory, or local domain used by your development environment.
How to Configure Magento Base URL for HTTPS
If your Magento store has an SSL certificate and you want to serve the website over HTTPS, update the secure Base URL to use https://.
For example:
https://www.example.com/
You should also configure Magento to use secure URLs where appropriate. After making the change, test the storefront, checkout, customer account pages, images, stylesheets, JavaScript, and internal links.
If your website is being redirected between HTTP and HTTPS repeatedly, check both Magento's URL configuration and your server or proxy redirect rules.
How to Change Magento Base URL From the Database
Sometimes you cannot access the Magento Admin Panel after changing a domain or server configuration. In that situation, you may need to update the Base URL directly in the Magento database.
Important: Always create a database backup before making direct database changes.
In Magento 1, Base URL values are stored in the core_config_data table. You can identify the relevant configuration records by looking for paths such as:
web/unsecure/base_urlweb/secure/base_url
The exact database operation should be performed carefully because changing configuration values incorrectly can make the Magento installation inaccessible.
After updating the database, clear the Magento cache and test the storefront.
Clear Magento Cache After Changing the Base URL
Magento may continue using cached configuration after you change the Base URL. Therefore, clearing the cache is an important part of the process.
From the Magento Admin Panel, navigate to the cache management section and refresh or clear the relevant cache types.
If you have access to the Magento filesystem, you may also need to clear appropriate Magento cache and generated files depending on your Magento version and setup.
After clearing the cache, open your website in a private/incognito browser window and test the important pages.
Common Magento Base URL Problems
1. Magento Redirects to the Old Domain
If Magento continues redirecting visitors to the old domain, check both the secure and unsecure Base URL values. Also inspect server-level redirects, reverse proxies, CDN settings, and cached configuration.
2. CSS and JavaScript Are Not Loading
Incorrect Base URL or static asset configuration can cause CSS and JavaScript files to load from the wrong location. Check the page source and browser developer tools to identify the URLs Magento is requesting.
3. Images Are Broken
Broken images can occur when Magento generates media URLs using an incorrect domain or protocol. Verify the Base URL and media-related configuration.
4. HTTPS Causes a Redirect Loop
A redirect loop may occur when Magento expects HTTPS but the web server or proxy reports the request as HTTP. Check your SSL termination, proxy configuration, Magento secure settings, and redirect rules.
5. Admin Panel Becomes Inaccessible
If you lose access to the Magento Admin Panel after changing the Base URL, verify the database configuration and server configuration. A database backup can help you safely restore the previous values if necessary.
Magento Base URL and SEO
The Base URL also has an indirect impact on technical SEO because Magento uses configured URLs when generating internal links and other website resources.
When changing your domain, pay particular attention to:
- Canonical URLs
- XML sitemaps
- Robots.txt
- Internal links
- 301 redirects
- HTTPS configuration
- Image URLs
- Product and category URLs
- Google Search Console settings
- Analytics and tracking configurations
If you are migrating to a new domain, do not simply change the Magento Base URL and assume the SEO migration is complete. Map important old URLs to their corresponding new URLs and implement appropriate permanent redirects.
Best Practices for Magento Base URL Configuration
- Use HTTPS for production websites.
- Use one preferred version of your domain.
- Keep secure and unsecure settings consistent with your site's architecture.
- Always back up the database before making direct database changes.
- Clear Magento cache after configuration changes.
- Test product, category, CMS, checkout, and account pages after changing the URL.
- Check for mixed-content warnings after switching to HTTPS.
- Review redirects when migrating to a new domain.
- Check canonical URLs and XML sitemaps after a domain migration.
Frequently Asked Questions About Magento Base URL
What is the Base URL in Magento?
The Magento Base URL is the primary website URL Magento uses to generate links and resource URLs throughout the store.
Where can I change the Magento Base URL?
In Magento 1, you can change it from System >> Configuration >> Web. The URL is configured under both the Unsecure and Secure sections.
Should Magento Base URL use HTTPS?
For a production store, HTTPS is generally recommended. Your Secure Base URL should use the HTTPS version of your domain when SSL is correctly configured.
Why is Magento redirecting to my old domain?
This can happen when the old domain is still stored in Magento's Base URL configuration, database, cache, server redirects, CDN configuration, or another application setting.
Why are my Magento images and CSS files broken after changing the domain?
Check whether Magento is generating asset URLs using the old domain or an incorrect HTTP/HTTPS configuration. Clear the cache and inspect the generated URLs in your browser's developer tools.
Do I need to clear Magento cache after changing the Base URL?
Yes. Clearing the Magento cache after changing configuration is recommended so that the store does not continue serving stale configuration or cached resources.
Can I change the Magento Base URL from the database?
Yes. In Magento 1, Base URL configuration values are stored in the core_config_data table. Always back up your database before making direct changes.
What should I check after changing the Magento Base URL?
Test your homepage, product pages, category pages, CMS pages, images, CSS, JavaScript, checkout, customer account pages, redirects, canonical URLs, and XML sitemap.
Conclusion
Correctly configuring the Magento Base URL is essential for maintaining a functional and accessible Magento store. Whether you are installing Magento on localhost, moving your store to a new domain, enabling HTTPS, or troubleshooting broken URLs, checking the secure and unsecure Base URL settings should be one of the first steps.
After changing the Base URL, remember to clear the Magento cache and thoroughly test your website. For domain migrations, also review redirects, canonical URLs, internal links, sitemaps, and other SEO settings to protect your organic search visibility.
If you need help with Magento development, migration, optimization, maintenance, or troubleshooting, visit ScriptBaker's blogs to learn more about how the team can help you plan and implement the right solution for your Magento store.
For more information visit our website ScriptBaker.com