After July 2021, the 2.3.x release line no longer received quality updates or user guide updates. PHP 7.3 reached end of support in December 2021, and Adobe Commerce 2.3.x reached end of support in September 2022. We strongly recommend upgrading to Adobe Commerce 2.4.x to help maintain PCI compliance.

Using a Custom Admin URL

This site contains archived merchant documentation for a version of Adobe Commerce and Magento Open Source that has reached end-of-support. The documentation available here is intended for historical reference only and is not maintained. The Adobe Commerce Merchant Documentation for current releases is published on the Adobe Experience League.

As a security best practice, Magento recommends that you use a unique, custom Admin URL instead of the default admin or a common term such as backend. Although it will not directly protect your site from a determined bad actor, it can reduce exposure to scripts that try to gain unauthorized access.

Check with your hosting provider before implementing a custom Admin URL. Some hosting providers require a standard URL to meet firewall protection rules.

In a typical Magento installation, the Admin URLĀ and path is immediately below the Magento base URL. The path to the store Admin is one directory below the root.

  • Default Base URL: https://yourdomain.com/magento/
  • Default Admin URL and Path: https://yourdomain.com/magento/admin

Although it is possible to change the Admin URL and path to another location, any mistake removes access to the Admin, and must be corrected from the server.

As a precaution, do not try to change the Admin URL yourself unless you know how to edit configuration files on the server.

Method 1: Change from the Magento Admin

  1. On the Admin sidebar, go to Stores > Settings > Configuration.

  2. In the left panel, expand Advanced and choose Admin.

  3. Expand Expansion selector the Admin Base URL section.

  4. Set the configuration options for the custom URL:

    Advanced configuration - Admin base URL Admin Base URL

    If needed, clear the Use system value checkbox to change the setting.

    • Set Use Custom Admin URL to Yes.

    • Enter the Custom Admin URL: https://yourdomain.com/magento/

      The Admin URL must be in the same Magento installation, and have the same document root as the storefront.

    • Set Custom Admin Path to Yes.

    • Enter the Custom Admin Path.

      The path that you enter is appended to the Custom Admin URL after the last forward slash.

      sample_custom_admin

  5. When complete, click Save Config.

  6. After the changes are saved, Sign Out of the Admin. Then, log back in using the new Admin URL and path.

Method 2: Change the Admin Path from the server command line

  1. Open the app/etc/env.php file in a text editor, and change the value of the frontName parameter of the backend section. Then, save the file.

    Make sure to use only lowercase characters.

    This method allows you to change the Admin Path, but not the Admin URL.

    • Default Admin Path
       'backend' => [
        'frontName' => 'admin'
       ],
      
    • New Admin Path
       'backend' => [
           'frontName' => 'backend'
       ],
      
  2. Use one of the following methods to clear the Magento cache:

    • On the Admin sidebar, go to System > Tools > Cache Management. Then, click Flush Magento Cache.
    • On the server, execute the following:
       php bin/magento cache:flush
      

    Note that the changes made using Method 1 will have priority over the changes made in the app/etc/env.php file.

Restore the default Admin URL and Admin Path

If you have set an invalid Admin URL or Admin Path and lost access to the backend, you can fix this from the command line.

  1. Execute this command to revert to the default Admin URL

    php bin/magento config:set admin/url/use_custom 0
    
  2. Execute this command to revert to the default Admin Path (set in the app/etc/env.php as described in the Method 2)

    php bin/magento config:set admin/url/use_custom_path 0
    
  3. Use one of the following methods to clear the Magento cache:

    • On the Admin sidebar, go to System > Tools > Cache Management. Then, click Flush Magento Cache.
    • On the server, execute the following:
       php bin/magento cache:flush