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

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

2 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

2 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

3 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

4 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

6 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

6 days ago