17

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

28

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. – mageDev0688 Apr 11 '17 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 '17 at 23:33
2

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

1

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 , http://127.0.0.1/admin

1

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`)
VALUES(
    'default', # Or whatever your Scope is
    0,         # Or whatever your Scope ID is
    'admin/url/use_custom',
    1
);
INSERT INTO `core_config_data`(`scope`, `scope_id`, `path`, `value`)
VALUES(
    'default', # Or whatever your Scope is
    0,         # Or whatever your Scope ID is
    'admin/url/custom',
    'https://my.url.com/newadminpath/'
);

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 at 8:50
  • Glad to help @Barry – Chris Rogers Sep 30 at 0:08
1

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

0

You need to follow below steps to change admin url

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

example:

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
0

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.

-1

best this ->

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

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