Setting custom admin url in magento 2 via CLI

In Magento 2, you can set the admin custom URL via the command line interface (CLI) using the bin/magento command. This can be useful for security purposes by changing the default /admin URL to something custom to make it harder for potential attackers to find your admin panel. Here are the steps to set the admin custom URL via CLI:

  1. Access Your Server via SSH:
    Connect to your server via SSH using your terminal or an SSH client.

  2. Navigate to Your Magento 2 Root Directory:
    Use the cd command to navigate to your Magento 2 installation directory:

    cd /path/to/your/magento2
  3. Set the Custom Admin URL:
    Use the bin/magento command to set the custom admin URL. Replace with the custom URL you want to set:

    bin/magento setup:config:set --backend-frontname=<your_custom_url>

    For example, if you want to set the custom admin URL to “myadmin,” you would run:

    bin/magento setup:config:set --backend-frontname=myadmin
  4. Clear the Configuration Cache:
    After setting the custom admin URL, clear the configuration cache to apply the changes:

    bin/magento cache:clean config
  5. Verify the Custom Admin URL:
    After completing the above steps, you can access the Magento admin panel using the custom URL you specified. For example, if you set the custom URL to “myadmin,” you can access the admin panel at

Please note that it’s essential to remember your custom admin URL as you’ll need it to access the admin panel in the future. Also, be cautious when changing the admin URL, and make sure you choose a unique and secure custom URL to protect your Magento store from unauthorized access.

Copyright © 2013-present All rights reserved.