MGT Cloud Log is here!

How to change Magento 2 backend url

October 19, 2016 - Stefan Wieczorek # Magento 2 Backend Url, Magento 2 backend frontname, Magento 2 Admin Path


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 could be easy identified by attacker. 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 the 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 to change it on a regulary basis.

Here are the steps to change the Magento 2 admin url:

1) Login into your Magento 2 Server with SSH

ssh your-username@$your-server-ip

2) Navigate to the Magento 2 directory e.g.

cd /home/cloudpanel/htdocs/

3) Use the Magento 2 CLI in order to change the backend url

php bin/magento setup:config:set --backend-frontname='secureAdmin123'

4) To check what your current Magento 2 backend url is, you can run the following command

php bin/magento info:adminuri

5) Another way to change the Magento 2 backend url is to edit the file app/etc/env.php

If you open the file it looks like the following excerpt:

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