Magento 2 Change Admin URL: How to Set a Custom Admin URL

How to Set a Custom Admin URL in Magento 2

Can we ask how you feel if your carefully built Magento store with proper products & copies, technical optimization with enhanced user experience, carefully curating your products, enhanced the user experience, and a lot of customer data lurking in the shadows of cybercriminals, who are always searching for an easy way to attack your tons of sales generating store.

And chances of an attack on your store increase if you’re still using the default Admin URL for your store, you might be unknowingly holding the door open for them.

Hackers and automated bots constantly scan the web, looking for vulnerabilities.

One of their favourite targets? Websites that haven’t changed their default Magento Admin URL.

It’s like leaving the key under the doormat—an open invitation for unauthorized access.

And if your passwords are easy to guess, you’re making their job even simpler.

While changing your Admin URL won’t make your site invincible, it does add a crucial layer of security.

Think of it as moving your front door to a hidden entrance—only those who know the way in can access it.

So, how can you do it?

Let’s explore the steps to change your default Magento Admin URL and make your store more secure.

If you want expert assistance, hiring dedicated Magento developers can ensure your store stays fully protected against potential threats.

Advantages of Changing the Magento 2 Admin URL

There are numerous benefits that you can get by customizing the default Admin URL in Magento 2, specifically in terms of security, usability, and store management.

Below we have mentioned some of the key advantages of setting up a custom Admin URL:

1. Protection Against Automated Attacks

It’s true that the momentum of the e-commerce industry is attracting more and more offline entrepreneurs to online stores, which has gained the eyesight of cyber criminals who are trying their best to search for any way to attack the security of e-commerce sites like Magento.

One of the common ways is done by programming many bots and automated scripts to target the default Magento admin path (/admin).

By using a unique and custom Admin URL, you significantly lower the chances of automated hacking attempts, keeping your store safer.

2. Increased Customer Confidence

Many Magento stores handle large amounts of sensitive data, whether it is related to personal information or payment processing, so if you change the Magento 2 Admin URL, then it will help protect sensitive customer data, including personal details and transaction information.

When shoppers know that their data is well-protected, they are more likely to trust your store and make purchases with confidence.

3. Enhanced Brand Identity

Customizing your Admin URL allows you to align it with your brand’s identity, making store management feel more personalized.

This small customization can also make accessing your backend feel more intuitive and professional.

4. Streamlined Multi-Store Management

If you have multi-stores in Magento 2, you might already be aware that it’s a very powerful tool offered by Adobe Commerce.

Moreover, in such a case sometimes it gets difficult to access the backend and avoid confusion between one store from another.

So, for businesses running multiple Magento stores, having distinct Admin URLs for each store makes it easier to differentiate and access the correct backend.

This improves efficiency and prevents confusion when managing multiple stores simultaneously.

How to Modify the Magento 2 Admin URL

1. Changing the Admin URL via the Magento Admin Panel

If you prefer a user-friendly method, you can change the Admin URL directly from the Magento Admin Panel.

Follow these steps:

  1. Log in to your Magento 2 store’s Admin Panel.
  2. Go to the Stores option > Configuration > Advanced > Admin.
  3. Extend the Admin Base URL section.
  4. Find the Use Custom Admin URL setting and switch it to Yes.
  5. Enter your desired Admin URL in the provided field.
  6. Click Save Config at the top of the page to apply the changes.
  7. Log out of the Admin Panel.
  8. Try accessing the store’s backend using the new Admin URL.

Read More: Understanding Magento 2’s Architecture: A Simple Yet Complete Guide

2. Changing the Admin URL Using Command Line Interface (CLI)

For developers who want to change the URL using the command line, changing the Admin URL via CLI is a quick and efficient approach.

  1. Connect to your Magento 2 store via SSH.

Run the following command: php bin/magento setup:config:set –backend-frontname=“your_custom_url”

  1. Replace “your_custom_url” with your preferred Admin URL.
  2. Give it a few seconds or minutes. so the command executes successfully.
  3. Verify that the Admin URL has been updated by attempting to log in with the new URL.

3. Changing the Admin URL Using the Database

Another way to modify the Admin URL is directly through the database.

This method is useful if you cannot access the Admin Panel or CLI.

  1. Log in to your store’s database using phpMyAdmin or any MySQL client.
  2. Locate the core_config_data table and open it.
  3. Search for the path column with the value “admin/url/custom”.
  4. Modify the corresponding value column, replacing it with your new Admin URL.
  5. Click the Go button to save the changes.
  6. Log out and attempt to log in using the newly configured Admin URL.

4. Changing the Admin URL Using the env.php File

If you have FTP or SSH access to your Magento 2 store, you can update the Admin URL by modifying the env.php configuration file.

  1. Use an SSH or FTP client (such as FileZilla) to connect to your server.
  2. Navigate to the app/etc/ directory.
  3. Locate and open the env.php file using a text editor.

Search for the following line: ‘frontName’ => ‘admin’,

  1. Replace ‘admin’ with your preferred Admin URL. Example: ‘frontName’ => ‘your_custom_url’,
  2. Save the file.
  3. Clear the Magento cache by running the following command: php bin/magento cache:flush
  4. The changes will take effect, and you can access your Admin Panel using the new URL.

Important Considerations Before Changing the Admin URL

  • Backup Your Store: Before making any modifications, always create a backup of your Magento 2 store, including files and the database.
  • Check for Third-Party Integrations: Some Magento extensions or integrations may depend on the Admin URL. Make sure to update any necessary settings.
  • Test Before Implementing: Always test the new Admin URL thoroughly in a staging environment before applying it to a live website.

Read More: Essential Steps for Setting Up a Magento 2 Local Development Environment

How to Restore the Default Admin URL and Admin Path

If you accidentally set an invalid Admin URL or Admin Path and lose access to the backend, you can restore the default settings using the command line.

Reset the Admin URL to the default value: php bin/magento config:set admin/url/use_custom 0

1. Reset the Admin Path to the default setting: php bin/magento config:set admin/url/use_custom_path 0

2. Clear the Magento cache:

  • Go to System > Tools > Cache Management from the Admin Panel.
  • Click Flush Magento Cache to apply the changes.

Best Practices for Choosing an Admin URL

  • Avoid Common Words: It would be better if you use a unique name that is hard to guess. Avoid using “admin” or “backend.”
  • Use Alphanumeric Characters: Include a mix of letters and numbers for added security, and this makes your URL clean, and easy to read.
  • Limit Access: Restrict access to the Admin URL with the help of an IP address if possible, using your server’s firewall or Magento’s IP restriction settings.

Recommended Read: Adobe Commerce vs Magento Open Source

Wrapping Up!

We have noticed that Magento merchants opt for various strategies to protect their store from cyber threats or leverage different tools and tactics to increase their sales, however sometimes they forget the basic thing, and Magento 2 admin URL is one of those criteria that helps in reducing the risk of automated attacks, protect sensitive customer data, and streamline backend management—especially if you’re running multiple stores.

Moreover, if you haven’t enough technical knowledge to implement these changes yourself, consider hiring experienced Magento developers from Mage Ecommerce which save you from major security headaches in the future.

Stay secure, stay ahead!

Author Image

Jeet is a seasoned e-commerce professional with 15+ years of experience in the Adobe Commerce ecosystem. Jeet specializes in Magento development, eCommerce B2B solutions, and automation processes, ensuring seamless integrations for clients. Passionate about driving business growth through innovative technology, he has helped companies and large-scale enterprises scale their online businesses, particularly in Magento 2 and Hyvä frameworks. When not working on e-commerce solutions, Jeet enjoys sharing industry insights through articles and thought leadership content pieces.

Leave a Reply

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