Hikmadh Commerce| Ecommerce Development Consulting | Magento Development and Consulting Service

How to Change Magento 2 Admin URL (3 Methods)

Introduction:

Changing the Magento 2 Admin URL is an essential step for enhancing the security of your Magento store. By modifying the default Admin URL, you can make it more difficult for potential attackers to target your store’s backend. In this guide, we will walk you through the process of changing the Magento 2 Admin URL, ensuring that you can safeguard your store’s sensitive information effectively

What is the Admin URL in Magento 2

The URL you use to access your Magento store’s admin panel is called Admin URL in Magento 2. The admin URL helps access the store’s backend and perform administrative tasks to view, edit, and manage order data, customer data, product catalog, store settings, extensions, and more. When you install Magento 2, it automatically creates your admin URL with some random string. The default admin URL in Magento 2 is yourdomain.com/magento/admin.

Reasons to Change Magento 2 Admin URL:

  • The default admin URL is susceptible to hackers.

 

  • Changing Admin URL will help in protecting your store from brute-force attacks.

 

  • Improve the security of your store by changing the admin URL.

 

  • Changing the admin URL is a recommended practice to secure your online store.

 

Things to Know Before Changing the Admin URL in Magento 2:

  • In case you cannot access your store admin panel after changing the URL, it is a good practice to have a Magento developer in the spare.

 

  • To avoid system downtime, it is a good practice to make changes in the URL in the development environment.

 

  • It is recommended to connect with your hosting provider to make sure they allow changing the URL.

 

  • If you are unaware of editing the configuration files on the server, changing the URL on your own is not recommended.

 

Ways to Change Magento 2 Admin URL:

You can change the admin URL of your Magento 2 store using any of the below mentioned three methods:

 

Method – 1 Change Admin URL using Admin Panel

 

  • From your admin panel, navigate to Stores > Settings > Configuration.

 

  • Enlarge the ADVANCED option and select Admin.

 

  • Now expand the Admin Base URL section.
  • Set Use Custom Admin URL to Yes.

 

  • Add your URL to the Custom Admin URL field ending with ‘/’.

 

  • Set Use Custom Admin Path to Yes.

 

  • Add your admin path to the Custom Admin Path field.

 

At last, click Save Config to save the changes. Then logout from the admin panel and log in again using the new URL.


Method – 2 Change Admin URL through Command Line


  • Login to Magento hosting server or SSH.

  • Move to your root directory.

  • Run the below command.

  •  php bin/magento setup:config:set --backend-frontname="custom_admin_path"

  • Set your desired URL in place of “custom_admin_path“.

  • Method – 3 Change Admin URL by Editing the Env.php File


  • Navigate to app/etc/env.php.

  • Now look into the code and find ‘frontName’ => ‘admin’,

  • Change the value within quotes like ‘frontName’ => ‘custom_admin_url’,

  • Now, clear the Magento cache

  • Conclusion:


    The steps outlined in this guide, you can successfully change the Magento 2 Admin URL, bolstering the security of your online store. Remember to choose a unique and memorable URL that is not easily guessable by potential attackers. Regularly updating your Magento store’s backend URL is a crucial aspect of maintaining a secure e-commerce environment. By taking proactive steps to protect your store’s administration area, you can help safeguard sensitive data, maintain customer trust, and ensure the smooth operation of your online business.