How to change admin URL in Magento 2

Starting from version 2.x of Magento 2, the admin URL name is generated automatically during the installation of the platform. This measure aims to improve the security of your store and prevent brute force attacks of the hackers on your store. Even though it is a great feature for the protection of a store, it is a complication for development.

Method №1: Using Console

–backend-frontname=”admin” — this command will establish the needed prefix for the admin URL. In this case, we will get:

php bin/magento setup:config:set –backend-frontname=”admin”
#clearing cache
php bin/magento cache:flush

Method №2: editing settings file env.php

Path to the file: ../app/etc/env.php

backend – frontName — Admin URL name is here. 

return [
    ‘backend’ => [
        ‘frontName’ => ‘admin’


Considering the importance of security measures related to the Admin URL, one of the essential considerations remains to be having a complex URL name to avoid hacker and bot attacks. Nevertheless, for development purposes, one may use a custom and accessible name before the full-scale launch of a store.

Related Articles

Notify of
Inline Feedbacks
View all comments