How To Change Admin URL In Magento 2

In this post, I will guide you on How To Change Admin URL In Magento 2. For security reasons, Magento recommends that store owners apply many methods to increase the security of their stores, avoiding the eyes of hackers. Changing the admin path is an effective security way to prevent hackers from accessing your store admin panel – a very important place, containing a lot of important information about your customers and your store.

Change Admin URL In Magento 2

Use Admin Panel

1. Log in to Admin Panel.

2. On the Admin Panel sidebar, go to Stores > Settings > Configuration.

3. In the left panel, choose ADVANCED > Admin.

4. Expand the Admin Base URL section.

Expand the Admin Base URL section

5. Untick Use system value and set Use Custom Admin URL and Use Custom Admin Path to “Yes”.

Untick Use system value and set Use Custom Admin URL and Use Custom Admin Path to Yes

6. Enter your Custom Admin URL and Custom Admin Path.

For example:

Custom Admin URL is: https://yourdomain.com/magento2/

Custom Admin Path is: admin

Note: Make sure that your Custom Admin URL ends with ‘/’ (slash).
Enter your Custom Admin URL and Custom Admin Path

7. Click Save Config when complete.

Run Magento 2 CLI

1.  First, you need to connect to your server via SSH as the root user by command:

ssh root@<your-ip-address> -p <your-port-number>

2. Go to Magento 2 root folder.

3. Run the command below to change admin path:

php bin/magento setup:config:set --backend-frontname="your_admin_path"

Edit env.php

  1. Open env.php file in the following path:
app/etc/env.php

2. Navigate to the backend and check the “frontName” property. You can see it in env.php file like this:

'backend' => [
        'frontName' => 'admin'
    ],

3. Change the value of ‘frontName’ parameter to admin_path you want.

Ex: We change ‘admin’ to ‘your_admin_path’. You can see the backend will look like this

'backend' => [
        'frontName' => 'your_admin_path'
    ],

4. Run flush cache command:

php bin/magento cache:flush

Follow us for the more helpful posts!

We hope this is a useful post for you.

You can read more useful posts like How To Change Default Admin Logo In Magento 2.

Thank you for reading!

4.8 5 votes
Article Rating

Aaron LX

Aaron is a passionate writer, crazy about shopping, eCommerce and trends. Besides his outstanding research skills and a positive mind, Aaron eagerly shares his experience with the readers.

Leave a Reply or put your Question here

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x