How to Change the Admin URL in Magento 2

Updated on Mar 13, 2019

Magento 2 has the option for you to type a custom Admin URL when you install it, but if you wish to later change your Admin URL again, you might find the option for it in the admin dashboard and as a result make your admin area inaccessible.

To change the Admin URL in Magento 2, you will have to:

step

Modify the evn.php file

To correctly change the admin URL of your Magento 2 website, you will need to first go into cPanel → FIle manager and find the file env.php located in:

/public_html/app/etc/

Right click on the file and select the Edit Code option.

Editing the enb.php file of Magento 2

Now you will need to change this line:

   'frontName' => 'admin'

By adding your new admin URL in the 'admin' field.

Changing the Admin URL value in the env.php file

Click on the Save Changes button at the top right corner and you are done with the file change.

step

Modify the Database

Now you will also need to modify a line in one of the tables of your Magento 2 database. You can do that, by navigating to the phpMyAdmin service located in your cPanel.

Accessing the phpMyAdmin service via cPanel

Click on the Database you use for the Magento 2 application and open the core_config_data table. Now look for the entry:

admin/url/custom

which will most likely be on page 11.

You will need to change the /admin part in http://yourdomain/admin to the same value you added in the env.php file by clicking on the Edit button for this entry.

Changing the Admin URL in the Magento 2 Database

When you are ready, click on the Go button to apply the change.

Congratulations, you have successfully changed the Admin URL for your Magento 2 Store.

On this page...

    Magento 2 Hosting

    • Free Installation
    • 24/7 Magento Support
    • Free Domain Transfer
    • Hack-free Protection
    • Fast SSD Storage
    • Free Cloudflare CDN
    • Free Magento Transfer
    • Immediate Activation
    View More