
How to change Magento 2 backend url
In this tutorial, we will show you how to change the Magento 2 backend url.
The Magento 2 admin url should not be admin or backend or any other easy path which the attacker could easily identify. The backend url can contain alphanumeric values, the underscore character _, and the dash character - only.
Having a unique admin path increases the security just a little bit.
The most secure way for your Magento 2 backend is to restrict access via IPs or VPN.
If you don't have the possibility to restrict the Magento 2 backend url via IPs or VPN, then we recommend changing it on a regular basis.
Here are the steps to change the Magento 2 admin url:
- Login into your Magento 2 Server with SSH.
ssh your-username-ssh@server-ip
- Go to the Magento 2 directory e.g.
cd /home/cloudpanel/htdocs/www.domain.com/
- Use the following command to set the Magento 2 backend url to
secureAdmin123
:
php7.4 bin/magento setup:config:set --backend-frontname='secureAdmin123'
Under the hood, Magento is making changes on the file app/etc/env.php
.
<?php
return [
'backend' => [
'frontName' => 'secureAdmin123'
],
That means that you can also just change the file app/etc/env.php
to change the Magento 2 backend url instead
of running the CLI command.
- To check what your current Magento 2 backend url is, you can run the following command:
php7.4 bin/magento info:adminuri