How to Change Magento 2 Admin URL (3 Methods)

Hello Magento Friends,

Today we will learn three ways to change the admin URL in Magento 2. First, let’s start with the basics of the Admin URL and the reasons to change it.

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.
  • Increase store protection by creating a custom 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

Wrapping Up:

Hence, these were the 3 ways to change the admin URL in Magento 2. Fix 404 Error Page Not Found in Admin URL in Magento 2. If you face difficulty altering the admin URL, you can connect with our Magento Developers to help you with it. 

Happy Reading!

Previous Article

How to Create Custom Swatch Attribute Programmatically in Magento 2?

Next Article

How to Implement Queue in Laravel 8?

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨