Once the installation is completed, is there a posibility to change admin url? If yes how can I do that?
7 Answers
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. Commented 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.– nshiffCommented 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 INTOcore_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/'); Commented 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`)
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– BarryCommented Sep 16, 2019 at 8:50
-
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
-
For those who are looking these are the path's:
admin/url/use_custom
andadmin/url/custom
mentioned in the more recent answer from chris rogers. Commented Oct 11, 2021 at 21:33
Quick answer (Using Magento 2 Admin settings):
- Log in the Magento 2 Admin interface
- Click Stores
- Click Configurations
- In the panel on the left, under Advanced, click Admin and expand the Admin Base URL section Set Use Custom Admin Path to “Yes”.
- Enter the Custom Admin Path. The path that you enter is appended to the
- Custom Admin URL after the last forward slash. For example:
testadmin
- 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 , http://127.0.0.1/admin
You need to follow below steps to change admin url
- 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
- 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.