How to change Magento 2 backend url

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.

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

  1. Login into your Magento 2 Server with SSH.
ssh your-username-ssh@server-ip
  1. Go to the Magento 2 directory e.g.
cd /home/cloudpanel/htdocs/
  1. 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.

return [
    'backend' => [
        'frontName' => 'secureAdmin123'

That means that you can also just change the file app/etc/env.phpto change the Magento 2 backend url instead of running the CLI command.

  1. To check what your current Magento 2 backend url is, you can run the following command:
php7.4 bin/magento info:adminuri
Shraddha S.
Shraddha S.
Head of Content

Shraddha Singh has a lot of thoughts about Technology and the Cloud Services Industry. An Indian native and a professional Technical writer, she gets her management skills from IIT-B.

Get the fastest Magento Hosting! Get Started