Magento Tutorials

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!

Click to rate this post!
[Total: 6 Average: 4.3]
Gaurav Jain

Gaurav Jain is Co-Founder and Adobe Certified Expert-Magento Commerce Business Practitioner. Being Computer Engineer?‍? and possessing Extensive Marketing skills he handles all kinds of customer Queries and his Happy? & Helping? Nature makes customer's day Delightful. When he isn’t working, you’ll find Gaurav Reading on Books? or Traveling?. Also, he is Speaker at Magento Meetups.

Recent Posts

Improving Error Handling and Transition Management in Remix with useRouteError and useViewTransitionState

In modern web development, seamless navigation and state management are crucial for delivering a smooth…

6 days ago

Magento Open Source 2.4.8-Beta Release Notes

Magento Open Source 2.4.8 beta version released on October  8, 2024. The latest release of…

1 week ago

How to Create Catalog Price Rule in Magento 2 Programmatically?

Hello Magento Friends, Creating catalog price rules programmatically in Magento 2 can be a valuable…

1 week ago

Top 10 Tips to Hire Shopify Developers

As the world of eCommerce continues to thrive, Shopify has become one of the most…

2 weeks ago

Managing Browser Events and Navigation in Shopify Remix: useBeforeUnload, useHref, and useLocation Hooks

Shopify Remix is an innovative framework that provides a streamlined experience for building fast, dynamic,…

2 weeks ago

Ultimate Guide to Hiring a Top Shopify Development Agency

Building a successful eCommerce store requires expertise, and for many businesses, Shopify has become the…

2 weeks ago