Once the installation is completed, is there a posibility to change admin url? If yes how can I do that?

7 Answers 7


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

  • After change the admin URL as the above process, I am getting 404 Not found issue. I have cleared the cache and run setup:static-content:deploy command. Apr 11, 2017 at 10:50
  • Regrettably, this had quite a negative effect on my environment. First of all, the route is not active. Second, I get quite an ugly error running magento setup:upgrade: ` [InvalidArgumentException] MySQL adapter: Missing required configuration option 'host'`. I resolved this by restoring an old version of app/etc/env.php - apparently this was corrupted by setup:config:set.
    – nshiff
    Jun 21, 2017 at 23:33
  • For the record, I used the "Change Admin URL" option mentioned above, however I also had to insert a couple of base_link_url records in the core_config_data table to get this to work. take.ms/mHbre INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('stores', 0, 'web/unsecure/base_link_url', 'admin.example.com/'), ('stores', 0, 'web/secure/base_link_url', 'admin.example.com/'); Dec 24, 2019 at 4:59

In Case You Cannot Access The Admin

If like me you could not access the admin in order to make the required change then on top of Amit Bera's answer, you will need to add a core_config_data configuration with the path:

INSERT INTO `core_config_data`(`scope`, `scope_id`, `path`, `value`)
    'default', -- Or whatever your Scope is
    0,         -- Or whatever your Scope ID is
INSERT INTO `core_config_data`(`scope`, `scope_id`, `path`, `value`)
    'default', -- Or whatever your Scope is
    0,         -- Or whatever your Scope ID is

Then run the CLI command:

php bin/magento setup:config:set --backend-frontname="newadminpath"
php bin/magento maintenance:enable 
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento maintenance:disable
  • Having read many answers, this it the one that saved me, most answers don't then layout the CLI commands to run
    – Barry
    Sep 16, 2019 at 8:50
  • Glad to help @Barry Sep 30, 2019 at 0:08

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

  • For those who are looking these are the path's: admin/url/use_custom and admin/url/custom mentioned in the more recent answer from chris rogers. Oct 11, 2021 at 21:33

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


you can change admin url using,

app/etc/env.php file

Change frontName equal to your required value,

'backend' => 
  array (
    'frontName' => 'admin', //keep your custom url name here

After changes your url, you must remove your var folder from root.

Now your admin url is like ,


You need to follow below steps to change admin url

  1. Go to app/etc/env.php and find 'frontName' and change that value


if your current admin url is www.yourdomain.com/admin then frontName value will be admin ('frontName' => 'admin' ) you need to change admin with your new word

  1. Run commands: static-content, reindex, cacha clean flush, di compilation

There are multiple ways to change the Admin URL in Magento 2.

Go to app/etc directory from the root directory of your store and open the env.php file in the text editor. Then change the frontName according to your choice:

return array (
 'backend' =>
 array (
   'frontName' => 'magento',

Lastly, run these commands:

rm -rf var/cache/*
php bin/magento cache:clean
php bin/magento cache:flush

You can also change it, via command line or through Admin Panel.

Not the answer you're looking for? Browse other questions tagged or ask your own question.