A lot of things changed in Magento 2, also some of it’s core feature too. For example Magento 2 Admin URL address. Each Magento 2 installation instance in fact generate a random Magento 2 Admin URL. The goal is to minimize the exposure to bots that want to gain unauthorized access to Magneto 2 Admin is minimized. In this post I will cover how to retrieve and how to change Magento 2 Admin URL.
In case you forgot your Magento 2 Admin URL, you can retrieve it by using the Magento 2 CLI. The following Magento 2 CLI command will give you the wanted information:
php bin/magento info:adminuri
Example of the result:
Admin Panel URI: /admin_test
You can also retrieve the the Admin URL in <your Magento install dir>/app/etc/env.php. Example:
'backend' => array ( 'frontName' => 'admin_test', ),
To change the randomly generated Magento 2 Admin URL, you can again use Magento 2 CLI or through Magento 2 Admin settings.
. The following command is here to help you:
php bin/magento setup:config:set --backend-frontname="newadminpath"
The system will ask you for the confirmation to overwrite the existing configuration for the backed-frontname. <
Overwrite the existing configuration for backend-frontname?[Y/n]
Just confirm with “Y”.
Y
The response should be something like that
You saved the new configuration.
Attention, be careful at choosing the new URL. Otherwise all the effort of the Magento 2 community at making this URL unique will vanish into darkness. Try to avoid common paths like admin, administration and backoffice.
If you are not a command line guy, you can also use the web interface to change the Magento 2 Admin URL. Here are the required steps:
Haven’t you tried Magento 2 on Docker yet? Check out my blog post Docker Magento 2 about it.