How to change magento2 admin url?

Change Admin Path

It is not recommended to change it directly from app/etc/env.php, always prefer the CLI:

php bin/magento setup:config:set --backend-frontname="admin_path"

Do not add the first / in the admin_path as it will result in an invalid parameter exception.

Change Admin URL

This can be done via the admin under Store > Advanced Tab > Admin Base URL section


One of coolest solution:

Goto magento >admin>Store>Advance>Admin Base Url>

Use Custom Admin URL field change value =YES

Then make Custom Admin URL as per as wise:

Note that: Make sure that base URL ends with '/' (slash), e.g. http://yourdomain/magento/

This will use If you want to change admin full url


If you want to change admin path then

make:Use Custom Admin Path =Yes and make Custom Admin Path as per as your wise

enter image description here


Quick answer (Using Magento 2 Admin settings):

  1. Log in the Magento 2 Admin interface
  2. Click Stores
  3. Click Configurations
  4. In the panel on the left, under Advanced, click Admin and expand the Admin Base URL section Set Use Custom Admin Path to “Yes”.
  5. Enter the Custom Admin Path. The path that you enter is appended to the
  6. Custom Admin URL after the last forward slash. For example: testadmin
  7. You will be logged out and redirected to the new Admin URL

Quick answer (Using CLI):

php bin/magento setup:config:set --backend-frontname="newadminpath"

Where newadminpath is the new Magento 2 Admin URL