How do I fix my Base URLs so I can access my Magento site?

  • I changed Base Urls and now my website is inaccessible
  • I moved everything to a new server, didn't change the base_url and my website is inaccessible

How do I change or restore base_url my BaseURL settings?

Solutions

In Magento2, there is also a way to do this directly via Magento using below commands rather than having to go through SQL which i find a bit quicker.

Within Magento’s root directory run below commands:

  1. Set Unsecure URL

    bin/magento setup:store-config:set --base-url="http://www.magento2.com/"
    
  2. Set Secure URL

    bin/magento setup:store-config:set --base-url-secure="https://www.magento2.com/"
    
  3. Clear Cache

    bin/magento cache:flush
    

Symptom: I changed Base Urls and now my website is inaccessible or I moved everything to a new server, didn't change the base_url and my website is inaccessible.

How to change or restore base_url settings with phpMyAdmin

Instructions are for a simple "one store" website where the "default store view" is set to inherit its setup from the "default config". There will be an additional instance of the below mentioned table rows for each unchecked Use Website checkbox.

  1. Open your core_config_data table in phpMyAdmin.

  2. Sort table by path column and find the following rows for your unsecure section, they should look like the following:

Columns

PATH                         VALUE
web/unsecure/base_url        http://www.example.com/
web/unsecure/base_link_url   {{unsecure_base_url}}
web/unsecure/base_skin_url   {{unsecure_base_url}}skin/
web/unsecure/base_media_url  {{unsecure_base_url}}media/
web/unsecure/base_js_url     {{unsecure_base_url}}js/
  1. Replace http://www.example.com/ with your appropriate domain url (trailing slash necessary) and if you’ve installed in a subfolder append it with a / after it.

  2. Find the following rows for your secure section, they should look like the following:

Columns

PATH                        VALUE
web/secure/base_url         https://www.example.com/
web/secure/base_link_url    {{secure_base_url}}
web/secure/base_skin_url    {{secure_base_url}}skin/
web/secure/base_media_url   {{secure_base_url}}media/
web/secure/base_js_url      {{secure_base_url}}js/
  1. Replace https://www.example.com/ with your appropriate domain url (trailing slash necessary) and if you've installed in a subfolder append it with a / after it. If you haven't received your security certificate and enabled TLS/SSL yet, use http instead of https

  2. Clear contents from var/cache, var/session directories after changing base_urls.

Clearing cache and sessions is necessary because your config is cached and clearing it forces a reread of the configuration data from the core_config_data table and reestablishment of sessions with the proper information.

NOTE: If you have set your base_url correctly for web/unsecure/base_url and web/secure/base_url you do not have to mess around with changing the {{UNSECURE_BASE_URL}} and {{SECURE_BASE_URL}} macros in the rest of the entries.

How to change base_url settings with mysql from the command line

  1. Log into your MySQL database, replace $USER with your database user name and $DBASE with your database name. It will prompt you for your password:

mysql -u $USER -p $DBASE

  1. Below are the SQL commands to change your base_url values. Replace unsecure http://www.example.com/ and secure https://www.example.com/ (if you have SSL/TLS enabled, else https should be http) with your appropriate domain url (trailing slash necessary) and if you’ve installed in a subfolder append it with a / after it.

SQL Commands

UPDATE core_config_data SET value = 'http://www.example.com/' WHERE path LIKE 'web/unsecure/base_url';
UPDATE core_config_data SET value = 'https://www.example.com/' WHERE path LIKE 'web/secure/base_url';
  1. Check your base_url settings with the following:

SQL Commands

SELECT path,value FROM core_config_data WHERE path LIKE 'web/unsecure/base%';
SELECT path,value FROM core_config_data WHERE path LIKE 'web/secure/base%';
  1. Clear contents from var/cache, var/session directories after changing base_urls. Clearing cache and sessions is necessary because your config is cached and clearing it forces a reread of the configuration data from the core_config_data table and reestablishment of sessions with the proper information.

Similar questions

How to fix LONG urls in magento for Layered navigation. SEO Practice
According to some SEO Practices having long URL is not good. Magento uses layered navigation and when you have lots of attributes then the URL becomes very very long. I can not put an URL here because the moderatos say its too localized. I just wanted to know if this is possible to fix using any kind of code? As I am not an expert on magento or php...
Re-direct from products' URLS with categories towards products' URLS without categories: how to do it?
this is my problem with my Magento-CMS based e-commerce: when the e-commerce was created, all products'URLS contained the categories. This means that for each product there could be several different URLS, beacuse of the categorization, but displaying the same content. I put an example here: the following 4 URLS all display the same content: http:/...
Include category path in product urls in sitemap and canonical urls
I am using magento-2.3 EE. I want to include category path in product url, in sitemap urls and same should be in their canonical urls. Like in sitemap, product urls should be like - site.com/category1/category2/product-name.html Similar structure should be in canonical urls of each product.
Fix module routes manually after installing PATCH SUPEE 6788 + toolbox fix
After running https://github.com/rhoerr/supee-6788-toolbox fix for patch supee 6788 some routes still go to 404 page. The fixSUPEE6788.log says for those cases "Admin routes for the module will have to be fixed manually". I don't know how to do that (replace what where). i.e Original route XML: I'm looking at the config.xml file for this module and...
Magento unsecure URLs set to https > can't access to admin and front
I am using Magento version 1.9.1 I have installed ssl certificates and given the base secure url as https://www.mydomain.com. I have also selected both the options : Use secure urls in frontend and Use Secure urls in admin. But it didn't worked, so I've tried to set the unsecure urls to https and I've saved it. Now I am not able to access into my a...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.