Today, we’re going to teach you guys how to change Magento 2 Admin URL of your online store.
Changing the admin URL is one of the most and highly-recommended practices to secure your online store from brute force and other types of cyberattacks.
And in this tutorial, we will show you guys 3 different methods to change admin URL in your Magento 2 store.
Method #1 - Change Admin URL from Admin Panel
The first method of changing admin URL in Magento 2 is the simplest one and even a non-technical person can learn it in first time.
First of all, open the admin panel and navigate to Store → Configuration.
After that, scroll down, find the “Advanced” tab, and click on the “Admin”.
Next, click on the “Admin Base URL” to expand the section and do as shown in the screenshot below.
Once it’s done, click on the “Save Config” to finish the process.
Method #2 - Change Admin URL from env.php File
The second method to change the admin URL of your Magento 2 store is by editing the env.php file.
So, navigate to app/etc folder and open the env.php file in a text editor.
Here, you’ll see code as following:
Now, to change the admin URL of your Magento 2 store, you need to replace the above code block with the following code:
Here, you can replace “magento” with any other custom path you’d like to use for the admin URL of your store.
Method #3 - Change Admin URL Using Command Line
The last method to change admin URL of your Magento 2 store is to change it via command line.
For this, you need to connect your store with an SSH terminal.
After that, go to the root directory of your store and execute the following command:
php bin/magento setup:config:set --backend-frontname="magento"
In the above command, we’ve set the new admin URL as “magento”, which you can change to anything you’d like.
Now, once you execute the command, remember to clean the cache.
Here are the commands you need to execute to clean cache:
rm -rf var/cache/*
php bin/magento cache:clean
php bin/magento cache:flush
And it’s done!
Concluding Thoughts…
There you have it!
These are the best 3 methods to change the admin URL of your Magento 2 store.
We hope that you found this tutorial helpful. If you have any doubts, please ask them in the comments below.
And if you need our professional assistance, feel free to contact us at any time.