How to configure base URLs for a Magento 1 website?

How to configure base URLs for a Magento 1 website?

In this article, we are going to change the base URLs of a Magento 1 website, using the swiss army knife for Magento developers, sysadmins and devops i.e. n98-magerun.

Base URLs can be also changed from the Magento Site backend as well as from the Database using phpMyadmin or Mysql REPL too.

Here, we are going to change base URLs of our Magento 1 website from https://from.magehost.cloud/ to https://to.magehost.cloud/ and configure the Magento 1 site to serve its js, css (skin) and images (media) from CDN.

To serve, content from CDN, we need another domain/sub-domain (lets' say cdn.magehost.cloud) for which CDN is enabled (i.e. cdn.magehost.cloud is proxied to serve content from the server running the Magento 1 site, and this content will be cached by the proxy server (CDN))

So, in this case the magento site can be accessed from https://from.magehost.cloud/ but now we will configure it to be accessible from https://to.magehost.cloud/ and configure CDN to serve the js, skin and media content.

Magento 1 stores all the crucial configuration in the Database in core_config_data table.

Before configuring the Magento site, make sure web-server (vHost) is configured for the domain/sub-domain ( i.e. vHost is configured for https://to.magehost.cloud/  and https://cdn.magehost.cloud/  ) and correct DNS records are set. (i.e https://to.magehost.cloud/ should point to the server and https://cdn.magehost.cloud/ has CDN configured)

To setup CDN, first make sure correct CORS headers are setup on the server.

In our cPanel Server Stack, to add a domain/sub-domain, perform the following steps:
  1. Login to the cPanel account and search for "Aliases" and click on it.
  2. To add a domain alias, enter the domain name in the text box.
  3. Click Add Domain.
  4. No redirections are required in this case, so click on "Disable Redirection" from the "Manage Redirection" option for the domain alias.
In cPanel Server Stack, there is already n98-magerun present on the server, and can be accessed with the command "magento-cli", yet n98-magerun can be easily downloaded via. (wget https://files.magerun.net/n98-magerun.phar)

Note : Use n98-magerun/magento-cli from the document root of the Magento site, as the cPanel account user.

To run a magento site on a domain/sub-domain we need to set the required base URLs in the core_config_data table.

Run following command to get the list of already set base URLs 
  1. magento-cli config:get '%base%url%';
The output will be somewhat similar to 



To change the base URL run the commands as shown below
  1. magento-cli config:set web/secure/base_url https://to.magehost.cloud/
  2. magento-cli config:set web/unsecure/base_url https://to.magehost.cloud/

  3. magento-cli config:set web/secure/base_js_url https://cdn.magehost.cloud/js/
  4. magento-cli config:set web/secure/base_media_url https://cdn.magehost.cloud/media/
  5. magento-cli config:set web/secure/base_skin_url https://cdn.magehost.cloud/skin/

  6. magento-cli config:set web/unsecure/base_js_url https://cdn.magehost.cloud/js/
  7. magento-cli config:set web/unsecure/base_media_url https://cdn.magehost.cloud/media/
  8. magento-cli config:set web/unsecure/base_skin_url https://cdn.magehost.cloud/skin/
The entry of {{secure_base_url}} OR {{unsecure_base_url}} in the value section means to use the value of web/secure/base_url and web/unsecure/base_url respectively.


Note : Don't forget to clear the caches after making the changes.
Clear the caches with
  1. magento-cli cache:clean
  2. magento-cli cache:flush
Re-check the base URLs after making changes, the output (magento-cli config:get '%base%url%') will be like


Make sure of the trailing slash '/' at the end of base URLs
Depending on the use cases, there could exist multiple base URLs with different "scope"s and their respective "scope-id"s

In short, There are three scope types - default, websites & stores.
  1. If scope is set to default then scope_id is always 0.

  2. If scope is set to websites then scope_id is website_id.

  3. If scope is set to stores then scope_id is store_id(store view).
Refer :- magento-cli config:set --help
  1. Usage:

    config:set [options] [--] <path> <value>

  2. Arguments:  

    path                                           The store config path like "general/local/code"
    value                                         The config value

  3. Options:
          
    --scope[=SCOPE]                            The config value's scope (default, websites, stores) [default: "default"]
    --scope-id[=SCOPE-ID]                   The config value's scope ID [default: "0"]

  4. Help:

    Set a store config value by path.
    To set a value of a specify store view you must set the "scope" and "scope-id" option.

So now we easily changed the base URLs (both secure and unsecure) from "https://from.magehost.cloud/" to "https://to.magehost.cloud/" and configured CDN to server js, media and skin content as well.

    • Related Articles

    • How to configure base URLs for a Magento 2 website?

      In this article, we are going to change the base URLs of a Magento 2 website, using the swiss army knife for Magento developers, sysadmins and devops i.e. n98-magerun2. Base URLs can be also changed from the Magento Site backend as well as from the ...
    • Magento Customer login does not work in Chrome browser

      Problem description Customers can not log in into Magento with Chrome browser, the login page just reloads without any errors or warnings. But when customer logins in other browsers and admin back-end login function properly. Cause Magento sets an ...
    • How to disable a website in virtualmin?

      To disable a website using virtualmin, follow the following steps :  Step 1:  Click on the Virtualmin section Step 2:  Select the Disable and Delete option Step 3:  Click on the Disable Virtual Server module Step 4:  Enter in a reason for disabling ...
    • How to enable a disabled website in virtualmin?

      Follow the steps below : Step 1:  Click on the Virtualmin section Step 2:  Select the disabled server from the drop down menu Step 3:  Select the Disable and Delete option Step 4:  Click on the Enable Virtual Server module Step 5:  Select if you’d ...
    • Using traceroute to troubleshoot network issues

      When you connect to a website, the traffic has to go through several intermediaries like your local router, your Internet service provider’s routers, onto larger networks, and so on. Traceroute shows us the path traffic takes to reach the website. It ...