How to Change Admin URL in Magento 2
Magento 2 is widely used CMS for E-commerce stores. Security, which is of prime importance, is given utmost priority in the CMS. Here, I’ll discuss one of the ways to implement security in the store, i.e., change admin URL in Magento 2.
The admin URL is used to access the backend of the store. It allows editing as well as manage the administrative tasks. However, the default format of the URL, “sitename.com/admin” is vulnerable to bots. It is easy to crack the predictable names such as a backend, admin, etc.
It is good practice to have a unique name of the admin URL that’ll help protect the backend admin from automated software’s hacks or bots attack. Experts recommend to change admin URL in Magento 2, hence I’ve come up with the method for the same!
Methods to Change Admin URL in Magento 2:
There are 3 methods to set custom Magento 2 admin URL:
-
via SSH
Run this command:
1php bin/magento setup:config:set --backend-frontname="admin_path"Here set whatever URL you wish to set in place of “admin_path“.
-
Manually
- Navigate to app/etc/env.php
- Change ‘frontName’ => ‘admin’,
- Clear cache
-
via Admin panel
- Log in the Admin panel
- Navigate to Stores > Configuration
- Click on Admin under Advanced section.
- Under Advanced, click Admin and expand the Admin Base URL section.
- Set Use Custom Admin URL to “Yes”.
- Enter the custom admin URL
- Also, you can enable the “Use Custom Admin Path” field and just set the custom admin path instead of the entire URL. This is an alternate method.
- You will be logged out and redirected to the new Admin URL.
These methods are handy to set custom admin URL in Magento 2. Though the method does not guarantee 100% security from bots, it does contribute to your efforts to secure the admin panel.
After using one of the methods to change the admin URL in Magento 2, you can type the new admin URL and log in as usual. Apart from securing the Magento 2 store against bots and attackers, changing your default admin URL is the tiny step towards the larger security endeavor.
For similar solution in Magento 1, check Change Admin URL in Magento.
Comment below if you face any issues in the implementation.
Enjoy secure Magento 2 store ?️
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
2 Comments
How to setup a custom admin subdomain? What are the changes needed at server level?
Hello Vivek,
You can change the admin URL and not subdomain with the above solution.
Thank you.