How to Change Magento Admin URL

Magento is one of the most widely used ecommerce platforms out there. The CMS  is recognized for its security as well as it is the most secure among many platforms for ecommerce stores. While there are many practices recommended for the security of Magento stores, one highly useful practice is to use a unique path for Magento admin panel URL rather than using the default URL. In this tutorial, I will teach you how to change Magento admin URL. I will show you multiple methods for changing the admin panel URL for both Magento 1.x and Magento 2.x.
Change Magento Admin Panel URL Change Magento 2 Admin Panel URL
Through the Admin Panel Through the Admin Panel
By Editing local.xml file By Editing the env.php
Via a Command Line

Change Magento Admin Panel

Method 1: Through the Admin Panel

The first step towards changing Magento admin URL is to go to the admin panel of your Magento store and then navigate to SYSTEM → Configuration: Now scroll down and click on Admin option under the ADVANCED tab: Now unfold Admin Base URL section and select Yes from Use Custom Admin Path drop-down menu and enter the admin path of your choice. I am using Magento, you can change it according to your requirements: Note: Don’t change Use Custom Admin URL option to Yes. Next, just click on Save Config button:

Method 2: By Editing local.xml file

Open the local.xml file in the text editor via the app/etc directory from the root directory of your Magento store. Here you will search for this code:
<admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
In the above code the Magento admin URL is set as admin, thus changing it to magento gives:
 <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[magento]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
You can use any of the above methods to change Magento Admin URL. Last but not least, don’t forget to clear the cache by navigating to System → Cache Management from the admin panel of your Magento store. Now let’s move to the methods for changing Magento 2 Admin URL.

Change Magento 2 Admin Panel URL

Method 1: Through the Admin Panel

Open the Admin panel of your store and navigate to STORES → Configuration Scroll down and click on Admin under ADVANCED. Now unfold the Admin Base URL section and make the changes in the same way as I have taught you for Magento 1.x:
Then, just click on Save Config:

Method 2: By Editing env.php

Open the env.php file in the text editor via app/etc directory from the root directory of your store. Now, you will see the following code:
<?php

return array (
 'backend' =>
 array (
   'frontName' => 'magento',
 )
Replace the above code with the following one to change Magento 2 Admin URL from admin to magento:
 'backend' =>
  array (
    'frontName' => 'magento',
  ),

Method 3: Via a Command Line

Connect your store with an SSH terminal and go to the root directory of your Magento 2 store. Now just run the following command: php bin/magento setup:config:set –backend-frontname=”magento” In the command above, I have set the admin URL path as magento, and you can set it according to your desire. I have mentioned and elaborated three methods for changing Magento 2 Admin URL. After using the method of your choice, you have to clean the cache. To do that, run the following commands in the Magento 2 root directory
rm -rf var/cache/*
php bin/magento cache:clean
php bin/magento cache:flush

Wrapping Up

Every ecommerce store must have a secure admin URL. After following this tutorial, you should now be able to change the Magento Admin URL. If you still have any confusion or want to discuss anything, feel free to use the comment box below! Also if you are looking to enable URL rewrite in Magento 2 see: How to Enable URL Rewrite in Magento 2

Frequently Asked Questions

Q1. Magento Admin URL not found on server: Why? You may be facing this issue because you are entering a wrong Magento Admin Panel URL. This can easily be corrected. For Magento 1.x, go to local.xml from app/etc directory and for Magento 2.x, go to env.php from app/etc directory. Q2. Why does Magento Admin URL still opens the old URL? It’s because you may have not cleared the cache of your store. Clear and flush it, then try opening your Magento admin panel URL.
Syed Muneeb Ul Hasan

Syed Muneeb Ul Hasan is an expert in PHP and Magento, he prefers to educate users in implementing and learning Magento. When not working, he loves to watch cricket.

View Comments

  • Please change Url to Path in the title of the article, please .... the current version is quite misleading .....

Share
Published by
Syed Muneeb Ul Hasan

Recent Posts

Building Employee Trust and Dedication – A Complete Guide

In the highly competitive modern workplace, trust, and employee loyalty are crucial factors for long-term… Read More

3 months ago

12 Winning Strategies for Small Businesses Marketing

In the ever-evolving world of small business developing and implementing effective marketing strategies is critical to… Read More

3 months ago

Top 10 App Development Companies in Dubai 2024

With one of the highest internet penetration rates, the UAE has set out to revolutionize… Read More

3 months ago

Transforming Industries: How Amazons GPT44X is Revolutionizing AI Technology

Artificial Intelligence (AI) has been continually evolving, leading to remarkable advancements in various industries. Among… Read More

8 months ago

Top Magento 2 Extensions for 2023

Extensions, extensions and lots of extensions. We all love extensions, don’t we? After all, extensions… Read More

11 months ago

Unleashing the Power of Software Testing: Cooperating with a Testing Firm

Software quality is crucial to a firm's success across industries in the quickly changing digital… Read More

11 months ago